#pragma init_seg(section-specifier, func-name) not supported
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
@llvm/issue-subscribers-clang-frontend
Author: Adam Glass (AdamGlass)
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
Hi!
This issue may be a good introductory issue for people new to working on LLVM. If you would like to work on this issue, your first steps are:
- Check that no other contributor is working on this issue. If someone is assigned to the issue or claimed to be working on it, ping the person. After one week without a response, the assignee may be changed.
- Leave a comment indicating that you are working on the issue, or just create a pull request after following the steps below. Mention this issue in the description of the pull request.
- Fix the issue locally.
- Run the test suite locally. Remember that the subdirectories under
test/create fine-grained testing targets, so you can e.g. usemake check-clang-astto only run Clang's AST tests. - Create a Git commit.
- Run
git clang-format HEAD~1to format your changes. - Open a pull request to the upstream repository on GitHub. Detailed instructions can be found in GitHub's documentation. Mention this issue in the description of the pull request.
If you have any further questions about this issue, don't hesitate to ask via a comment in the thread below.
@llvm/issue-subscribers-good-first-issue
Author: Adam Glass (AdamGlass)
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
Hi, I would like to contribute to this thanks @AdamGlass
Our team would like to work on this
Our team would like to work on this
In general, we assign after a PR is created.
Since this was inactive for some time, I decided to open PR to fix the issue. See #203769
@shafik sir can I work on this
@competitive-programmer04 this feature is already implemented.
@rnk @shafik Could you please trigger CI in the linked PR above? Thank you
@competitive-programmer04 this feature is already implemented.
@rnk @shafik Could you please trigger CI in the linked PR above? Thank you
It looks like the branch needs to be updated.