Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix C2491 error on MSVC #784

Closed
wants to merge 1 commit into from
Closed

Fix C2491 error on MSVC #784

wants to merge 1 commit into from

Conversation

ntkme
Copy link

@ntkme ntkme commented Jun 22, 2023

This PR fixes C2491 errors on the latest version of MSVC by splitting the __declspec(dllimport) declaration and definition into two statements.


https://learn.microsoft.com/en-us/troubleshoot/developer/visualstudio/cpp/language-compilers/c2491-define-data-member-dllimport

//defining data member
extern __declspec(dllimport) int code = 1;
// error C2491: 'code' : definition of dllimport data not allowed
// declaring data member
extern __declspec(dllimport) int code; // ok
int code = 1;

@ntkme ntkme closed this Jun 25, 2023
@ntkme ntkme deleted the fix-msvc-c2491 branch June 25, 2023 13:12
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Compilation Error on MSVC Build Tools v143
1 participant