[cfe-users] G++ & Clang++ - namespace std _GLIBCXX_VISIBILITY(default)

Adam Brenner aebrenne at uci.edu
Tue Nov 5 11:42:27 PST 2013

I am trying to compile my C++ code using `clang++` but keep getting this error
with the conflicting namespace. My main.cpp file is a simple Hello World
program (for debugging).

I have a feeling the issue is related to a lack of includes or environment
variables I need to set up. On our HPC cluster, I am using the module's
system[1] but for the purpose of debugging, everything is being done via the
command line.

    [aebrenne at hpc src]$ gcc -v
    Using built-in specs.
    Target: x86_64-unknown-linux-gnu
    Configured with: ./configure --with-gmp=/data/apps/gmp/5.1.2
--with-mpfr=/data/apps/mpfr/3.1.2 --with-mpc=/data/apps/mpc-1.0.1
--enable-threads=posix --with-as=/data/apps/binutils/2.23.2/bin/as
--mandir=/data/apps/gcc/4.8.1/man --pdfdir=/data/apps/gcc/4.8.1/pdf
    Thread model: posix
    gcc version 4.8.1 (GCC)

    [aebrenne at hpc src]$ clang++ --version
    clang version 3.4 (trunk 193367)
    Target: x86_64-unknown-linux-gnu
    Thread model: posix
    [aebrenne at hpc src]$

    [aebrenne at hpc src]$ cat main.cpp
    #include <iostream>

    int main() {
    std::cout << "Starting test..." << std::endl;

    return 0;
    [aebrenne at hpc src]$ clang++ -std=c++11 -Wall -g
-I/data/apps/gcc/4.8.1/include/c++/4.8.1  main.cpp
    In file included from main.cpp:1:
    In file included from /data/apps/gcc/4.8.1/include/c++/4.8.1/iostream:39:
    In file included from /data/apps/gcc/4.8.1/include/c++/4.8.1/ostream:38:
    In file included from /data/apps/gcc/4.8.1/include/c++/4.8.1/ios:38:
    In file included from /data/apps/gcc/4.8.1/include/c++/4.8.1/iosfwd:39:
    In file included from
error: expected '{'
    namespace std _GLIBCXX_VISIBILITY(default)
error: C++ requires a type specifier for all declarations
    namespace std _GLIBCXX_VISIBILITY(default)
error: expected expression
    namespace std _GLIBCXX_VISIBILITY(default)
error: expected ';' after top level declarator
    namespace std _GLIBCXX_VISIBILITY(default)

[1]: http://modules.sourceforge.net

Adam Brenner
Computer Science, Undergraduate Student
Donald Bren School of Information and Computer Sciences

Research Computing Support
Office of Information Technology

University of California, Irvine
aebrenne at uci.edu

More information about the cfe-users mailing list