Let say we have 3 .cpp in our project as below:

//abc.cpp
#include <iostream>
class abc
{
    public:
        static int sabc;
};

int abc::sabc = [](){std::cout << "init abc" << std::endl; return 0;}();

//abcd.cpp
#include <iostream>
class abcd
{
    public:
        static int sabcd;
};

int abcd::sabcd = [](){std::cout << "init abcd" << std::endl; return 0;}();

//test.cpp
int main()
{    
    return 0;
}

Given above .cpp, I build the test executable and run it by following 
typing:

>em++ -std=c++11 abc.cpp abcd.cpp -o abc.bc
>em++ -std=c++11 abc.bc test.cpp -o test.js
>node test.js
init abc
init abcd

As we see in the output, those static class variables will be initialized 
ahead due to unused abc.obj and abcd.obj will be linked to final 
executable. Is there any way to prevent these unused objs to be linked into 
final executable so that those global variables in them will not be 
initialized? 

-- 
You received this message because you are subscribed to the Google Groups 
"emscripten-discuss" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
For more options, visit https://groups.google.com/d/optout.

Reply via email to