[ros-dev] Compiler-independence for 64-bit integral constants
tamlin at algonet.se
Sat Oct 9 18:08:16 CEST 2004
Currently there are quite a few places in ROS src where 64-bit integral
constants are either hard-coded to be GNU C only (?), or almost worse
littered with conditional compilation.
Neither is satisfactory. 1 is making it impossible to compile using e.g. an
MS compiler, and 2 makes the code so ugly that... Well, you understand.
So, in the interest of fixing this once and for all, the only option is to
name a macro to handle these compiler specifics in one place, and then use
that macro when defining 64-bit integral constants. The question is then,
what to name it? The macro will be defined something like (omitting unsigned
#if defined __GNUC__
#define ZZZ(X) X##LL
#elif defined _MSC_VER
#define ZZZ(X) X##i64
#error Unknown compiler for 64-bit integral constant suffix
Serious suggestions that have surfaced so far are:
If suggesting something else, keep in mind that
- while short might be beautiful (and fast to type), using short macros is
likely to sooner or later create conflicts.
- leading underscore followed by capital character or another underscore is
not legal for C++.
- It's to make it clear that it's a 64-bit int defined, why suggestions
mentioning LL or i64, as in compiler-specific extensions/implementation
details, are likely not to help or be accepted since that's exactly what we
want to get away from.
More information about the Ros-dev