ycm-core / YouCompleteMe

A code-completion engine for Vim
http://ycm-core.github.io/YouCompleteMe/
GNU General Public License v3.0
25.47k stars 2.81k forks source link

ycm_core fails build on FreeBSD 9.1 #260

Closed ashemedai closed 11 years ago

ashemedai commented 11 years ago

Using the latest git version (as of 2013-04-21) when I try to build ycm_core I run into this build issue:

[ 86%] Building CXX object BoostParts/CMakeFiles/BoostParts.dir/libs/thread/src/pthread/thread.cpp.o
Linking CXX static library libBoostParts.a
[ 86%] Built target BoostParts
Scanning dependencies of target ycm_core
[ 86%] Building CXX object ycm/CMakeFiles/ycm_core.dir/Candidate.cpp.o
/home/asmodai/.vim/bundle/YouCompleteMe/cpp/ycm/Candidate.cpp:47:22: error: 'nullptr' is incompatible with C++98 [-Werror,-Wc++98-compat]
  LetterNode *node = NULL;
                     ^
/usr/include/sys/_null.h:35:14: note: expanded from macro 'NULL'
#define NULL    nullptr

The CXXFLAGS turn out to be: CXX_FLAGS = -stdlib=libc++ -std=c++0x -Wall -Wextra -Werror -Wc++98-compat -Wno-long-long -Wno-variadic-macros -Wno-missing-field-initializers -Wno-unused-private-field -O3 -DNDEBUG -isystem

Using -std=c++0x sets clang++ 3.2 to define __cplusplus as 201103L, basically saying it's operating at C++11 level, which actually allows for nullptr, so erroring out on c++98 compatibility seems odd at best.

FreeBSD 9.1-STABLE (April 2013) with FreeBSD clang version 3.2 (tags/RELEASE_32/final 170710) 20121221 Target: x86_64-unknown-freebsd9.1 Thread model: posix

Valloric commented 11 years ago

YCM sets the -Wc++98-compat warning flag. This is there so that I don't accidentally introduce a C++11 feature into what is supposed to be a C++03 codebase (which I still want to compile in C++11 mode because of move ctors etc).

Your system appears to be doing something incredibly unwise which is to #define NULL nullptr. Your /usr/include/sys/_null.h file probably detects that the compilation mode is C++11 and then sets that. It's still a bad idea though, NULL is not nullptr and effectively doing a global search/replace of NULL to nullptr will lead to issues like these.

Replacing -std=c++0x with -std=c++03 in the compiler flags should get it to compile (you may also need to remove the -stdlib=libc++ flag). If it works, please inform me and I'll add a check to the cmake build scripts for FreeBSD.

[You could also just remove the -Wc++98-compat flag]