cartman
cartman

Reputation: 752

Identify version of c++ (e.x. c++11, c++14) from the object or library file

I was wondering if there's any tool in GNU or LLVM toolchains that can help to get the c++ version info from a object or library?

Upvotes: 1

Views: 642

Answers (1)

Ruslan
Ruslan

Reputation: 19100

I've just made a test with a simple .o file containing the compiled version of the following code:

#include <iostream>

void test()
{
    std::cout << "Hello\n";
}

I compiled it using the command:

for std in 03 11 14 17; do g++ test.cpp -std=c++$std -c -o test$std.o; done

Now I checked SHA1 sums of the resulting object files

$ sha1sum test*.o
f4805c820db889327a90c823f3515baed1f443dc  test03.o
2437e0d7aaf2dcf0575eff1237cad70ebef06448  test11.o
2437e0d7aaf2dcf0575eff1237cad70ebef06448  test14.o
f4805c820db889327a90c823f3515baed1f443dc  test17.o

As you can see, the object files for C++03 vs C++17, as well as for C++11 vs C++14, are identical. Thus there's no general way to distinguish between these, unless your code is compiled with some special options (of which I'm unaware).

Upvotes: 3

Related Questions