zoo
zoo

Reputation: 1911

Library works with Clang but not with GCC

Why does this library work perfectly with Apple LLVM 5.0 (clang-500.2.79), while merely including the header file causes an error with GCC 4.9?

Minimal source file that produces the error:

#include <divsufsort.h>

int main() {  
  return 0;
}

The error I get with GCC 4.9:

In file included from main.cpp:1:0:
/usr/local/include/divsufsort.h:74:1: error: expected constructor, destructor, or type conversion before '(' token
 DIVSUFSORT_API
 ^
/usr/local/include/divsufsort.h:86:1: error: expected constructor, destructor, or type conversion before '(' token
 DIVSUFSORT_API
 ^
/usr/local/include/divsufsort.h:94:1: error: expected constructor, destructor, or type conversion before '(' token
 DIVSUFSORT_API
 ^
/usr/local/include/divsufsort.h:108:1: error: expected constructor, destructor, or type conversion before '(' token
 DIVSUFSORT_API
 ^
/usr/local/include/divsufsort.h:123:1: error: expected constructor, destructor, or type conversion before '(' token
 DIVSUFSORT_API
 ^
/usr/local/include/divsufsort.h:137:1: error: expected constructor, destructor, or type conversion before '(' token
 DIVSUFSORT_API
 ^
/usr/local/include/divsufsort.h:152:1: error: expected constructor, destructor, or type conversion before '(' token
 DIVSUFSORT_API
 ^
/usr/local/include/divsufsort.h:169:1: error: expected constructor, destructor, or type conversion before '(' token
 DIVSUFSORT_API

Upvotes: 0

Views: 376

Answers (1)

selbie
selbie

Reputation: 104464

I suspect that you need to run ./configure on the libdivsufsort directory again with the CC environment variable pre-set for the compiler you intend to use. (CC for "c" code. CXX for c++ code). Then rebuild.

cd ~/libdivsufsort-2.0.1
make clean
CC=gcc
CXX=g++
./configure
make

Try this link: Configuring for a compiler different than the default while running configure

Upvotes: 2

Related Questions