
Wed, 01/11/2012 - 17:38
Forums:
In OSD_FileNode.cxx, from line 17 :
#if!defined(TM_IN_SYS_TIME) && defined(HAVE_TIME_H)
# include
#elif HAVE_SYS_TIME_H
# include
#endif
#elif HAVE_SYS_TIME_H should be replaced with #elif defined(HAVE_SYS_TIME_H)
Max
Thu, 01/12/2012 - 10:59
Dear Massimo,
You are welcome to develop a corresponding patch and make a contribution via the Collaborative portal - http://dev.opencascade.org/index.php?q=home/get_involved.
This will benefit all.
Regards
Thu, 01/12/2012 - 11:19
Guys,
To be clear.
This is not a bug and the results will be the same.
#if _MACRO_ is equivalent to #ifdef _MACRO_ or #if defined(_MACRO_) as long as _MACRO_ is not 0.
The only value add in this case will be syntax consistency.
I myself tend to prefer #if _MACRO_ syntax as it's shorter and more flexible.
Roman
Thu, 01/12/2012 - 13:52
I don't know if it should be the same, but with GCC it isn't.
On my system the compiler complains about this as an error,
not a warning.
I know that usually I can write #if or #ifdef, but I'm not sure about #elif.
Max
Thu, 01/12/2012 - 14:20
This just means you HAVE_SYS_TIME_H is either undefined (and hence #else defined won't help) or it is default as 0.
Anyway, you might want to check config.h.
Thu, 01/12/2012 - 14:49
#else defined DO help, because if I change it it works without any syntax error.
------------------------------------------------------
#define SOMETHING
#define ANOTHERTHING
int main(int argc, const char *argv[])
{
int a;
#ifdef SOMETHING
a = 1;
#elif ANOTHERTHING <-- error: #elif with no expression
a = 2;
#else
a = 3;
#endif
------------------------------
int main(int argc, const char *argv[])
{
int a;
#ifdef SOMETHING
a = 1;
#elif defined(ANOTHERTHING) <-- NO ERROR HERE
a = 2;
#else
a = 3;
#endif
Max
Thu, 01/12/2012 - 14:54
Argh, my bad!
Should be
#else if
of course. #elif with undefined macro leads to error of course.
Sorry for confusion.
Thu, 01/12/2012 - 14:59
np. :-)
It's the first time I encounter this kind of bug... I wasn't sure either.
Usually for configuration macros I prefere to use #ifdef, which allow macro defined
with any value, rather than #if which requires to be != 0, but it's a matter of taste, I guess.
BTW, IMHO c preprocessor is missing some #elifdef macro :-)
Max
Thu, 01/12/2012 - 17:16
Hello, your fix is right, but I compile OCC with different versions of GCC and never encountered this error, so I am curious: what is your GCC error message exactly, and which version of GCC do you use?
Thu, 01/12/2012 - 18:08
Hi Denis,
the error is exactly the one I've reported : "error: #elif with no expression"
The GCC is the one supplied with Ubuntu Natty, 4.6.1.
When I made my tests I've seen that error happens only in some conditions, depending on which of both variables are #defined (don't remember exactly when....); if you run my test sample above you'll get the error. Probably if you use the
#define XXXXX 1
instead of the
#define XXXXX
you won't get the error... but I'm not sure about.
I found it because I'm using a custom config file.
Max