Important Notice: Our web hosting provider recently started charging us for additional visits, which was unexpected. In response, we're seeking donations. Depending on the situation, we may explore different monetization options for our Community and Expert Contributors. It's crucial to provide more returns for their expertise and offer more Expert Validated Answers or AI Validated Answers. Learn more about our hosting issue here.

What is this llvm.global_ctors and _GLOBAL__I__tmp_webcompile… stuff that happens when I #include ?

happens stuff
0
Posted

What is this llvm.global_ctors and _GLOBAL__I__tmp_webcompile… stuff that happens when I #include ?

0

If you #include the header into a C++ translation unit, the file will probably use the std::cin/std::cout/… global objects. However, C++ does not guarantee an order of initialization between static objects in different translation units, so if a static ctor/dtor in your .cpp file used std::cout, for example, the object would not necessarily be automatically initialized before your use. To make std::cout and friends work correctly in these scenarios, the STL that we use declares a static object that gets created in every translation unit that includes . This object has a static constructor and destructor that initializes and destroys the global iostream objects before they could possibly be used in the file. The code that you see in the .ll file corresponds to the constructor and destructor registration code. If you would like to make it easier to understand the LLVM code generated by the compiler in the demo page, consider using printf() instead of iostreams to p

Related Questions

What is your question?

*Sadly, we had to bring back ads too. Hopefully more targeted.

Experts123