Home Bug Reports

problem in C++ include file ordering

I don't know if this really can be called a bug, anyway the effect of this issue is not nice:

if I have a test.ice and include the following header files:
#include <stdint.h>
#include <test.h>

the file will not compile, because:

the generated test.h includes IceUtil/Config.h
which sets the parameter __STDC_LIMIT_MACROS and afterwards includes <stdint.h>

but, if stdint.h has already been included before, it won't be included a second time and the INT64_MAX ... macros won't be defined and the compiler exits with an error at the lines:
    198 // Assumes ISO C99 types
    199 //
    200 typedef int64_t Int64;
    201 const Int64 Int64Min = INT64_MIN;
    202 const Int64 Int64Max = INT64_MAX;

in IceUtil/Config.h with the error message that INT64_MIN and INT64_MAX are not defined.

I think this is not really a nice way to include stdint.h ;) but I have to admit I don't know if using one of the other methods which already are in IceUtil.h could deliver all needed variables.

greetings,
Peter

Comments

  • michimichi Member Michi HenningOrganization: Triodia TechnologiesProject: I have a passing interest in Ice :-) ✭✭✭
    Hmmm... I don't think there is anything much we can do about this. This really is a shortcoming of the entire #include and preprocessing machinery.

    I'd suggest to always put the Ice headers first, followed by any system headers. That way, the problem can't arise (and that's what we do in our own code.)

    Cheers,

    Michi.
Sign In or Register to comment.