Re: "char *" diff in header & func arg list?

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Hi kourama,

These two things are mostly interchangeable for most purposes as a
parameter:

char array[];
char* pointer;

On the caller's side, arg1 degenerates into something that almost is the
same as:

char* const arg1;

C proponents would say this is a good thing.  I've been working in C++ long
enough to consider it a bit of a wart (but C++ has far more atrocious warts
than this to worry about), as part of the C legacy.


However, this is an outright mismatch:

extern char array[];
extern char* pointer;

char array[] = "good";
char pointer[] = "bad";

Why?  Because an array of characters is not a pointer to an array of
characters.  The declaration does not match the definition.

> So, is this a bug, legacy behaviour or is this just another wrinkle in the
sharpei puppy that is C?

In this case, not a wrinkle, not a "legacy C" issue.  It is a PEBKAC bug.

HTH,
--Eljay


[Index of Archives]     [Linux C Programming]     [Linux Kernel]     [eCos]     [Fedora Development]     [Fedora Announce]     [Autoconf]     [The DWARVES Debugging Tools]     [Yosemite Campsites]     [Yosemite News]     [Linux GCC]

  Powered by Linux