c++ - Problem with enums and preprocessor
- Charles Sanders (32/32) Sep 20 2003 Still trying to port libcurl, lots of enums ill give to shorten examples
- Gisle Vanem (10/26) Sep 21 2003 Because, I think DMC's preprocessor isn't fully ISO compatible.
- Walter (19/33) Sep 21 2003 Try deleting code prior to the error message until the error goes away, ...
- Charles Sanders (9/47) Sep 22 2003 Odly, if i use a file with .cpp extension, the header problems go away. ...
- Charles Sanders (14/71) Sep 22 2003 This unfortunately brings about other issues (using names like private,
Still trying to port libcurl, lots of enums ill give to shorten examples typedef enum { CURLOPT_NOTHING = 0, CURLOPT_FOO = 202 } CURLoption; This produces : ../include\curl/curl.h(684) : Error: 'CURLOPT_NOTHING' is already defined This is the only place CURLOPT_NOTHING is even mentioned I get the same results using a regular enum enum { CURLOPT_FOO = 202 } Whats up ? It also seems the preprocessor stumbles alot on the macros, we have this #define number typedef enum { CURLOPT_NOTHING = 0, /* This is the FILE * or void * the regular output should be written to. */ CINIT(FILE, OBJECTPOINT, 1), /* The full URL to get/put */ CINIT(URL, OBJECTPOINT, 2), /* Port number to connect to, if other than default. */ CINIT(PORT, LONG, 3), /* Name of proxy to use. */ CINIT(PROXY, OBJECTPOINT, 4), ... So far I have had to change all these by hands ( or with a short script ) but Im wondering why this is not supported ? Thanks Charles
Sep 20 2003
"Charles Sanders" <sanders-consulting comcast.net> wrote:#define number typedef enum { CURLOPT_NOTHING = 0, /* This is the FILE * or void * the regular output should be written to. */ CINIT(FILE, OBJECTPOINT, 1), /* The full URL to get/put */ CINIT(URL, OBJECTPOINT, 2), /* Port number to connect to, if other than default. */ CINIT(PORT, LONG, 3), /* Name of proxy to use. */ CINIT(PROXY, OBJECTPOINT, 4), ... So far I have had to change all these by hands ( or with a short script ) but Im wondering why this is not supported ?Because, I think DMC's preprocessor isn't fully ISO compatible. Try to patch curl.h: #if (defined(__STDC__) || defined(_MSC_VER) || defined(__cplusplus) || \ defined(__HP_aCC) || defined(__BORLANDC__)) && !defined(__DMC__) /* This compiler is believed to have an ISO compatible preprocessor */ #define CURL_ISOCPP #else --gv
Sep 21 2003
"Charles Sanders" <sanders-consulting comcast.net> wrote in message news:bkj5b0$jqe$1 digitaldaemon.com...Still trying to port libcurl, lots of enums ill give to shorten examples typedef enum { CURLOPT_NOTHING = 0, CURLOPT_FOO = 202 } CURLoption; This produces : ../include\curl/curl.h(684) : Error: 'CURLOPT_NOTHING' is already defined This is the only place CURLOPT_NOTHING is even mentionedTry deleting code prior to the error message until the error goes away, to see what causes it. The CINIT macro must be generating another CURLOPT_NOTHING earlier in the source text.It also seems the preprocessor stumbles alot on the macros, we have this #define numberThe following code: ----------------------------------- #define number int CURLOPT_foo; int CURLOPTTYPE_bar; void test() { CINIT(foo,bar,57); } ----------------------------------- compiles and generates the expected code.So far I have had to change all these by hands ( or with a short script ) but Im wondering why this is not supported ?There must be something else happening in the code you're using outside of the examples you posted.
Sep 21 2003
Odly, if i use a file with .cpp extension, the header problems go away. Ill try to build it forcing the compiler to use CPP. Thanks, C "Walter" <walter digitalmars.com> wrote in message news:bkkpt5$sr6$1 digitaldaemon.com..."Charles Sanders" <sanders-consulting comcast.net> wrote in message news:bkj5b0$jqe$1 digitaldaemon.com...definedStill trying to port libcurl, lots of enums ill give to shorten examples typedef enum { CURLOPT_NOTHING = 0, CURLOPT_FOO = 202 } CURLoption; This produces : ../include\curl/curl.h(684) : Error: 'CURLOPT_NOTHING' is already+This is the only place CURLOPT_NOTHING is even mentionedTry deleting code prior to the error message until the error goes away, to see what causes it. The CINIT macro must be generating another CURLOPT_NOTHING earlier in the source text.It also seems the preprocessor stumbles alot on the macros, we have this #definescript )numberThe following code: ----------------------------------- #define number int CURLOPT_foo; int CURLOPTTYPE_bar; void test() { CINIT(foo,bar,57); } ----------------------------------- compiles and generates the expected code.So far I have had to change all these by hands ( or with a shortbut Im wondering why this is not supported ?There must be something else happening in the code you're using outside of the examples you posted.
Sep 22 2003
This unfortunately brings about other issues (using names like private, protected ), I tried just compiling the DLL with VC6 ( this is all to create D wrappers for libcurl ) using implib on the def file which works but I get runtime errors ( failed to initalize ). I hope SWIG gets completed soon (couldnt find an executable ). C "Charles Sanders" <sanders-consulting comcast.net> wrote in message news:bknr9o$2sgf$1 digitaldaemon.com...Odly, if i use a file with .cpp extension, the header problems go away.Illtry to build it forcing the compiler to use CPP. Thanks, C "Walter" <walter digitalmars.com> wrote in message news:bkkpt5$sr6$1 digitaldaemon.com...examples"Charles Sanders" <sanders-consulting comcast.net> wrote in message news:bkj5b0$jqe$1 digitaldaemon.com...Still trying to port libcurl, lots of enums ill give to shortentodefinedtypedef enum { CURLOPT_NOTHING = 0, CURLOPT_FOO = 202 } CURLoption; This produces : ../include\curl/curl.h(684) : Error: 'CURLOPT_NOTHING' is alreadyThis is the only place CURLOPT_NOTHING is even mentionedTry deleting code prior to the error message until the error goes away,typesee what causes it. The CINIT macro must be generating another CURLOPT_NOTHING earlier in the source text.It also seems the preprocessor stumbles alot on the macros, we have this #define++numberThe following code: ----------------------------------- #defineofnumber int CURLOPT_foo; int CURLOPTTYPE_bar; void test() { CINIT(foo,bar,57); } ----------------------------------- compiles and generates the expected code.script )So far I have had to change all these by hands ( or with a shortbut Im wondering why this is not supported ?There must be something else happening in the code you're using outsidethe examples you posted.
Sep 22 2003