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

msvc compilation issue with "Simplify windows handling (#1903)" #1904

Closed
NelsonEloi opened this issue Sep 27, 2020 · 8 comments
Closed

msvc compilation issue with "Simplify windows handling (#1903)" #1904

NelsonEloi opened this issue Sep 27, 2020 · 8 comments

Comments

@NelsonEloi
Copy link

Good day,

If in your code you already include <windows.h>, this commit causes some problems,

As is it will cause the following error
error C2733: 'WriteConsoleW': you cannot overload a function with 'extern "C"' linkage
1>C:\Program Files (x86)\Windows Kits\10\Include\10.0.19041.0\um\consoleapi.h(244,1): message : see declaration of 'WriteConsoleW'

I've trying changing the signature back to using Windows defines to see what happens and then I get
extern "C" BOOL __stdcall WriteConsoleW( HANDLE hConsoleOutput,
CONST VOID* lpBuffer,
DWORD nNumberOfCharsToWrite,
LPDWORD lpNumberOfCharsWritten,
LPVOID lpReserved );
warning C4273: 'WriteConsoleW': inconsistent dll linkage
1>C:\Program Files (x86)\Windows Kits\10\Include\10.0.19041.0\um\consoleapi.h(244,1): message : see previous definition of 'WriteConsoleW'

The best compromise I manage was to use your signature but change the extern "C" to __declspec( dllimport )
__declspec( dllimport ) int __stdcall WriteConsoleW( void* hConsoleOutput,
const void* lpBuffer,
uint32_t nNumberOfCharsToWrite,
uint32_t* lpNumberOfCharsWritten,
void* lpReserved );

Thank very much for your wonderful library
Nelson

@NelsonEloi NelsonEloi changed the title msvc compilation issue wtih "Simplify windows handling (#1903)" msvc compilation issue with "Simplify windows handling (#1903)" Sep 27, 2020
@vitaut
Copy link
Contributor

vitaut commented Sep 27, 2020

I wasn't able to repro this: https://ci.appveyor.com/project/vitaut/fmt/builds/35421078. Please provide the full error message including source locations.

@NelsonEloi
Copy link
Author

Hello,

Please find attached and example, at line 2886 of format-inl.h you'll find a comment out 'WriteConsoleW' that works

Complete error is:
1>------ Build started: Project: test, Configuration: Debug x64 ------
1>Source.cpp
1>C:\test\fmt\include\fmt\format-inl.h(2886,26): error C2116: 'WriteConsoleW': function parameter lists do not match between declarations
1>C:\Program Files (x86)\Windows Kits\10\Include\10.0.19041.0\um\consoleapi.h(244): message : see declaration of 'WriteConsoleW'
1>C:\test\fmt\include\fmt\format-inl.h(2886,26): error C2733: 'WriteConsoleW': you cannot overload a function with 'extern "C"' linkage
1>C:\Program Files (x86)\Windows Kits\10\Include\10.0.19041.0\um\consoleapi.h(244,1): message : see declaration of 'WriteConsoleW'
1>Done building project "test.vcxproj" -- FAILED.
========== Build: 0 succeeded, 1 failed, 0 up-to-date, 0 skipped ==========

test.zip

Thank you very much

@vitaut
Copy link
Contributor

vitaut commented Sep 27, 2020

I tried to repro on godbolt since I don't have a Windows machine at hand, but to no avail: https://godbolt.org/z/fYhcbW. What MSVC version do you use?

@NelsonEloi
Copy link
Author

In godbolt I can reproduce it if I remove the namespace detail, and I'm at a loss with this, because if the namespaces are different we shouldn't have a conflict, or I'm missing something

My version is:
Microsoft Visual Studio Professional 2019 Version 16.7.4
cl.exe -> Microsoft (R) C/C++ Optimizing Compiler Version 19.27.29111 for x64
sdk -> 10.0.19041.0

godbold sdk is 10.0.18362.0

https://godbolt.org/z/aWe43r

@NelsonEloi
Copy link
Author

Got it, its related with the Conformance mode /permissive-

https://godbolt.org/z/b88hTc

@vitaut
Copy link
Contributor

vitaut commented Sep 28, 2020

Thanks for the repro; should be fixed in 79694d4.

@vitaut
Copy link
Contributor

vitaut commented Sep 28, 2020

#1905

@vitaut vitaut reopened this Sep 28, 2020
@vitaut
Copy link
Contributor

vitaut commented Sep 28, 2020

Fixed declspecs in 3ae8814.

@vitaut vitaut closed this as completed Sep 28, 2020
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

No branches or pull requests

2 participants