public inbox for gcc-help@gcc.gnu.org
 help / color / mirror / Atom feed
* Problems with #import <stdarg.h>
@ 2009-07-23 10:39 Ronald Pijnacker
  2009-07-23 13:28 ` John (Eljay) Love-Jensen
  0 siblings, 1 reply; 2+ messages in thread
From: Ronald Pijnacker @ 2009-07-23 10:39 UTC (permalink / raw)
  To: gcc-help; +Cc: Ronald Pijnacker

Hi all,

When I include stdarg.h after stdio.h using objc's #import I get the error:

$ gcc -c stdarg.m
stdarg.m: In function 'func':
stdarg.m:6: error: 'va_list' undeclared (first use in this function)
stdarg.m:6: error: (Each undeclared identifier is reported only once
stdarg.m:6: error: for each function it appears in.)
stdarg.m:6: error: expected ';' before 'ap'
stdarg.m:7: error: 'ap' undeclared (first use in this function)

when I switch the two around, it is ok.

Thanks,

Ronald

^ permalink raw reply	[flat|nested] 2+ messages in thread

* RE: Problems with #import <stdarg.h>
  2009-07-23 10:39 Problems with #import <stdarg.h> Ronald Pijnacker
@ 2009-07-23 13:28 ` John (Eljay) Love-Jensen
  0 siblings, 0 replies; 2+ messages in thread
From: John (Eljay) Love-Jensen @ 2009-07-23 13:28 UTC (permalink / raw)
  To: Ronald Pijnacker, gcc-help

Hi Ronald,

I believe* all the operating system provided headers (such as the Standard C Library ones) expected to be #include'd (which uses the C protocol for the preprocessor), not #import'd (the ObjC protocol for the preprocessor).

Using #import can interfere with their multi-include logic.  The reason for the multi-include logic is historical/legacy, evolutionary, backwards compatibility, and also involves ISO 9899 standardization (both 1989 and 1999).  And for some headers, which are more intimately tied to the operating system than the Standard C Library, there may be some POSIX (IEEE Std 1003) contortions as well or UNIX 2003 contortions.  It's hard to please everyone.

In theory, they could be made to be #import savvy as well, but those headers are really C headers, not ObjC headers.  (Often they have allowances incorporated to be used as-is for C++.  But C++ compilation units really should use <cstdarg> and <cstdio> rather than the raw C <stdarg.h> and <stdio.h> anyway.)

HTH,
--Eljay

* I may be mistaken.

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2009-07-23 13:28 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2009-07-23 10:39 Problems with #import <stdarg.h> Ronald Pijnacker
2009-07-23 13:28 ` John (Eljay) Love-Jensen

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).