llvm/llvm-project

#pragma init_seg(section-specifier, func-name) not supported

Open

#148.938 geöffnet am 15. Juli 2025

Auf GitHub ansehen
 (6 Kommentare) (0 Reaktionen) (1 zugewiesene Person)C++ (10.782 Forks)batch import
clang:frontendextension:microsoftgood first issueplatform:windows

Repository-Metriken

Stars
 (26.378 Stars)
PR-Merge-Metriken
 (Durchschn. Merge 1T 2h) (1.000 gemergte PRs in 30 T)

Beschreibung

This MSVC pragma is only partially implemented. As detailed here, there is functionality to specify a function to call in place of atexit.

https://learn.microsoft.com/en-us/cpp/preprocessor/init-seg?view=msvc-170

"func-name Specifies a function to be called in place of atexit when the program exits. This helper function also calls atexit with a pointer to the destructor for the global object. If you specify a function identifier in the pragma of the form,

C++

Copy int __cdecl myexit (void (__cdecl *pf)(void)) then your function will be called instead of the C run-time library's atexit. It allows you to build a list of the destructors to call when you're ready to destroy the objects."

Relevant code in ParsePragma.cpp:Parser::HandlePragmaMSInitSeg: // FIXME: Add support for the '[, func-name]' part of the pragma.

Maybe a good early OSS contribution given the limited use and lack of potential for regression

Contributor Guide