[NTLUG:Discuss] C questions
Steve Baker
sjbaker1 at airmail.net
Tue Sep 20 00:00:02 CDT 2005
Fred James wrote:
> All
> Can anyone confirm for me that
> //
> is not an allowed syntax for a commnet line in ANSI C, please?
> (example:
> // line of text
> should be
> /* line of text */
> )
That is correct. C++ style comments (the '//' kind) are allowed
by many C compilers - but they aren't STRICTLY legal for C code.
The reason for this is that most C compilers are also C++ compilers
and it's pretty trivial for them to allow C++ comments in C programs.
> Can anyone confirm for me that
> _EXPORT is not a part of extern in ANSI C, please?
I can confirm that. It's a Microsoft-ism.
Microsoft had some kind of problem with the C way of linking
separate compilations...so they added a bunch of garbage to
the language to cover their inadequacies.
"Embrace and Extend"....words to live by.
> (example:
> extern _EXPORT DataTable* createDataTable();
> should be
> extern DataTable* createDataTable();
> )
Most portable programs have something like:
#ifdef WINDOWS
#define MYEXPORT _EXPORT
#else
#define MYEXPORT
#endif
...at the top of the file and then...
extern MYEXPORT Datatable* createDataTable() ;
This is ugly - but necessary if you wish your programs to go over
to The Dark Side.
---------------------------- Steve Baker -------------------------
HomeEmail: <sjbaker1 at airmail.net> WorkEmail: <sjbaker at link.com>
HomePage : http://www.sjbaker.org
Projects : http://plib.sf.net http://tuxaqfh.sf.net
http://tuxkart.sf.net http://prettypoly.sf.net
-----BEGIN GEEK CODE BLOCK-----
GCS d-- s:+ a+ C++++$ UL+++$ P--- L++++$ E--- W+++ N o+ K? w--- !O M-
V-- PS++ PE- Y-- PGP-- t+ 5 X R+++ tv b++ DI++ D G+ e++ h--(-) r+++ y++++
-----END GEEK CODE BLOCK-----
More information about the Discuss
mailing list