Project

General

Profile

Task #1126

./configure should detect whether compiler is C++11 enabled

Added by Junxiao Shi over 7 years ago. Updated over 7 years ago.

Status:
Closed
Priority:
Normal
Target version:
Start date:
01/22/2014
Due date:
% Done:

100%

Estimated time:
1.00 h

Description

Code branch: cawka/ndn-cpp, new-dev
Platform: Ubuntu Precise
Compiler: g++ 4.6.3-1ubuntu5, automake 1.11.3-1ubuntu2, libtool 2.4.2-1ubuntu1
Configure command: ./autogen.sh

Error message:

libtool: compile:  g++ -DHAVE_CONFIG_H -I. -I./include -g -O2 -std=gnu++0x -MT src/common.lo -MD -MP -MF src/.deps/common.Tpo -c src/common.cpp  -fPIC -DPIC -o src/.libs/common.o
In file included from src/common.cpp:9:0:
./include/ndn-cpp-dev/common.hpp:18:2: error: #error "NDN-CPP-DEV library is configured and compiled in C++11 mode, but the current compiler is not C++11 enabled"
#1

Updated by Junxiao Shi over 7 years ago

Workaround: ./autogen.sh --without-c++11

#2

Updated by Alex Afanasyev over 7 years ago

  • Status changed from New to Rejected
  • Target version set to dev

This is not related (directly) to ndn-cpp. The current default in ndn-cpp (in dev too) is to use c++11 when availabe. The deafault (for "safety" reasons) in other applications (the daemon, security tools, etc.) is not to use c++11 unless specifically enabled with ./waf configure --with-c++11.

#3

Updated by Junxiao Shi over 7 years ago

The problem is: ./autogen.sh and/or ./configure thinks C++11 is available, but libtool complains that compiler is not C++11 enabled.

The code in question is:
#if (__cplusplus < 201103L)
#error "NDN-CPP-DEV library is configured and compiled in C++11 mode, but the current compiler is not C++11 enabled"
#endif

g++ -std=gnu++0x -dM -E x.cpp (where x.cpp is an empty file) shows that:
#define __cplusplus 1

This is a behavior caused by gcc bug 1773, which is not fixed until gcc 4.7.
ndn-cpp should provide a workaround for gcc 4.6, in order to support Ubuntu 12.04.

#4

Updated by Alex Afanasyev over 7 years ago

  • Status changed from Rejected to New

Ohh.. Got it now. Ok, this is definitely a problem.

I think the only problem is that __cplusplus does not really reflect whether the compiler supports C++11 (c++0x). The whole check is for applications, so they don't use non-c++11-enabled compiler when library is compiled in c++11 mode...

Do you have a suggestion how to solve this problem? What could be a workaround? Directly checking gcc version?

If ./configure by default would not force c++11, would this be a reasonable workaround?

#5

Updated by Junxiao Shi over 7 years ago

automake should be used to detect the features needed, and define a macro for each feature.

Code should condition on those feature detection macros, instead of detecting the compiler or standard version.

#6

Updated by Alex Afanasyev over 7 years ago

For normal applications- yes. But this particular check it is not for applications, rather than for apps that want to compile against the library. You cannot guarantee that other apps will check how cpp library was compiled and this macro aimed to caution the developers (deployers) that configuration is wrong. I could change it to just warning, so it would not prevent compilation if it is false positive.

#7

Updated by Alex Afanasyev over 7 years ago

  • Status changed from New to Resolved
  • % Done changed from 0 to 100
  • Estimated time set to 1.00 h
#8

Updated by Alex Afanasyev over 7 years ago

  • Status changed from Resolved to Closed

Also available in: Atom PDF