[galib] Issues with modern compilers

Jerry Gagelman gagelman at gmail.com
Mon Aug 29 13:25:37 EDT 2011


I have gotten GAlib to build with g++; my exact compiler details are:
i686-apple-darwin11-llvm-g++-4.2 (GCC) 4.2.1 (Based on Apple Inc. build
5658) (LLVM build 2335.15.00)

Out of curiosity I tried to build it with the clang++ compiler :
Apple clang version 2.1 (tags/Apple/clang-163.7.1) (based on LLVM 3.0svn)
Target: x86_64-apple-darwin11.1.0
Thread model: posix

I have noticed that Clang will issue warnings for things that GCC doesn't,
but I have never seen it fail to compile things that GCC will, since both
compilers use the same LLVM backend. However Clang chokes on the
file GA1DArrayGenome.C...

libtool: compile:  clang++ -DPACKAGE_NAME=\"ga\" -DPACKAGE_TARNAME=\"ga\"
-DPACKAGE_VERSION=\"2.4.7\" "-DPACKAGE_STRING=\"ga 2.4.7\""
-DPACKAGE_BUGREPORT=\"galib-bugs at mit.edu\" -DPACKAGE_URL=\"\"
-DPACKAGE=\"ga\" -DVERSION=\"2.4.7\" -DSTDC_HEADERS=1 -DHAVE_SYS_TYPES_H=1
-DHAVE_SYS_STAT_H=1 -DHAVE_STDLIB_H=1 -DHAVE_STRING_H=1 -DHAVE_MEMORY_H=1
-DHAVE_STRINGS_H=1 -DHAVE_INTTYPES_H=1 -DHAVE_STDINT_H=1 -DHAVE_UNISTD_H=1
-DHAVE_DLFCN_H=1 -DLT_OBJDIR=\".libs/\" -DHAVE_LIMITS_H=1 -DHAVE_STDDEF_H=1
-DHAVE_STDLIB_H=1 -DHAVE_STRING_H=1 -DHAVE_UNISTD_H=1 -DHAVE__BOOL=1
-DHAVE_STDBOOL_H=1 -DHAVE_FLOOR=1 -DHAVE_GETHOSTNAME=1 -DHAVE_MEMMOVE=1
-DHAVE_MEMSET=1 -DHAVE_POW=1 -DHAVE_SELECT=1 -DHAVE_SQRT=1 -I. -I.. -g -O2
-MT GAStringGenome.lo -MD -MP -MF .deps/GAStringGenome.Tpo -c
GAStringGenome.C  -fno-common -DPIC -o .libs/GAStringGenome.o
In file included from GAStringGenome.C:11:
In file included from ../ga/GAStringGenome.h:14:
In file included from ../ga/GA1DArrayGenome.h:178:
../ga/GA1DArrayGenome.C:225:3: error: use of undeclared identifier
'initializer'
  initializer(GA1DArrayAlleleGenome<T>::DEFAULT_1DARRAY_ALLELE_INITIALIZER);
  ^
../ga/GA1DArrayGenome.C:226:3: error: use of undeclared identifier 'mutator'
  mutator(GA1DArrayAlleleGenome<T>::DEFAULT_1DARRAY_ALLELE_MUTATOR);
  ^
../ga/GA1DArrayGenome.C:241:3: error: use of undeclared identifier
'initializer'
  initializer(GA1DArrayAlleleGenome<T>::DEFAULT_1DARRAY_ALLELE_INITIALIZER);
  ^
../ga/GA1DArrayGenome.C:242:3: error: use of undeclared identifier 'mutator'
  mutator(GA1DArrayAlleleGenome<T>::DEFAULT_1DARRAY_ALLELE_MUTATOR);
  ^
4 errors generated.


When I trace back through this using Xcode, it seems that GA1DArrayGenome.C
is included in GA1DArrayGenome.h due to the GALIB_USE_BORLAND_INST flag
being defined, though this is difficult to corroborated.

The failure to build with the Clang/Clang++ compilers is not something that
I consider urgent. However I have noticed that definitions
like GALIB_USE_BORLAND_INST are set in the ..ga/gaconfig.h header.

This presents an unfortunate situation. The compiler is essentially sent on
a "choose-your-own-adventure" path through the dense logic of preprocessor
macros once the gaconfig.h header is loaded. This will only make GAlib more
brittle and harder to maintain as compilers and architectures continue to
evolve. A potential fix to this situation is to let a true build
configuration system (like CMake or Autotools) generate the gaconfig.h
header without all of the #if defined(__COMPILERX__) styled logic gates.

If there is sufficient community interest, I would be willing to submit a
prototype.

Jerry
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://mailman.mit.edu/pipermail/galib/attachments/20110829/acabb8a4/attachment.htm


More information about the galib mailing list