Re: Offline Tutorial



In article <1179438839.909509.196060@xxxxxxxxxxxxxxxxxxxxxxxxxxx>,
Tejas Kokje <binarysemaphore@xxxxxxxxx> wrote:

Ok.that may be for C89 or K & R C. But can somebody show me a C99
program which won't compile under C++ compiler ? I am just curious.

int main(void)
{
char *namespace = "http://example.org";;
return 0;
}

"namespace" is a keyword in C++.

I have written C code which turned out to have this problem, and
"namespace" was used as a struct tag in a header, which made
it impossible to link with C++. The code was already in use, so
I didn't want to change the name. I ended up doing this:

#ifdef __cplusplus
/* unfortunately the word "namespace" is reserved in C++ */
#define RXP_NAMESPACE name_space
#else
#define RXP_NAMESPACE namespace
#endif

and referring to RXP_NAMESPACE throughout the header.

-- Richard


--
"Consideration shall be given to the need for as many as 32 characters
in some alphabets" - X3.4, 1963.
.



Relevant Pages