-
September 28th, 2021, 01:47 AM
#1
#warning and MSVC
AFAICT it's not supported in MSVC but it seems to be much more common now for 3rd-party source code to contain #warning message lines. Is there any way they can be converted into something that'll work in MSVC but still work in the other compilers? (a #pragma maybe?) Or if not, is there some way to configure MSVC so that it'll ignore the #warning lines?
"A problem well stated is a problem half solved.” - Charles F. Kettering
-
September 28th, 2021, 03:08 AM
#2
Re: #warning and MSVC
All advice is offered in good faith only. All my code is tested (unless stated explicitly otherwise) with the latest version of Microsoft Visual Studio (using the supported features of the latest standard) and is offered as examples only - not as production quality. I cannot offer advice regarding any other c/c++ compiler/IDE or incompatibilities with VS. You are ultimately responsible for the effects of your programs and the integrity of the machines they run on. Anything I post, code snippets, advice, etc is licensed as Public Domain https://creativecommons.org/publicdomain/zero/1.0/ and can be used without reference or acknowledgement. Also note that I only provide advice and guidance via the forums - and not via private messages!
C++23 Compiler: Microsoft VS2022 (17.6.5)
-
September 28th, 2021, 03:35 AM
#3
Re: #warning and MSVC
Thanks 2kaud but I think that's intended for the official (i.e. numeric) warnings. OTOH #warning is generally followed by a user-defined text message
"A problem well stated is a problem half solved.” - Charles F. Kettering
-
September 28th, 2021, 07:13 AM
#4
Re: #warning and MSVC
If #warning is just to display a warning message at compile time, then perhaps #pragma comment ??
https://docs.microsoft.com/en-us/cpp...?view=msvc-160
All advice is offered in good faith only. All my code is tested (unless stated explicitly otherwise) with the latest version of Microsoft Visual Studio (using the supported features of the latest standard) and is offered as examples only - not as production quality. I cannot offer advice regarding any other c/c++ compiler/IDE or incompatibilities with VS. You are ultimately responsible for the effects of your programs and the integrity of the machines they run on. Anything I post, code snippets, advice, etc is licensed as Public Domain https://creativecommons.org/publicdomain/zero/1.0/ and can be used without reference or acknowledgement. Also note that I only provide advice and guidance via the forums - and not via private messages!
C++23 Compiler: Microsoft VS2022 (17.6.5)
-
September 29th, 2021, 03:02 AM
#5
Re: #warning and MSVC
Thanks 2kaud but if I'm reading that article correctly, #pragma comment is for inserting a comment into the compiled file.
Over on StackOverflow someone suggested using #pragma NOTE. It doesn't actually display anything but at least it allows the compile to continue. So what'd be nice would be some magic to convert #warning statements into #pragma NOTE. But AFAICT this can't be done with #define (#define doesn't like seeing another # in the command).
"A problem well stated is a problem half solved.” - Charles F. Kettering
-
September 29th, 2021, 03:16 AM
#6
Re: #warning and MSVC
How about #pragma message ?
https://docs.microsoft.com/en-us/cpp...?view=msvc-160
#pragma NOTE is not listed as a supported #pragma for MSVS.
All advice is offered in good faith only. All my code is tested (unless stated explicitly otherwise) with the latest version of Microsoft Visual Studio (using the supported features of the latest standard) and is offered as examples only - not as production quality. I cannot offer advice regarding any other c/c++ compiler/IDE or incompatibilities with VS. You are ultimately responsible for the effects of your programs and the integrity of the machines they run on. Anything I post, code snippets, advice, etc is licensed as Public Domain https://creativecommons.org/publicdomain/zero/1.0/ and can be used without reference or acknowledgement. Also note that I only provide advice and guidance via the forums - and not via private messages!
C++23 Compiler: Microsoft VS2022 (17.6.5)
-
September 29th, 2021, 04:14 AM
#7
Re: #warning and MSVC
Wow, that looks even better - but I'd still need a way to convert #warning "whatever" into #pragma message("whatever")
"A problem well stated is a problem half solved.” - Charles F. Kettering
-
September 29th, 2021, 04:39 AM
#8
Re: #warning and MSVC
How many of them are there?
Can you use a #ifdef ... to choose between the 2 versions depending upon the compiler used? Something like:
Code:
#if defined (_MSC_VER)
#pragma message("message")
#else
#warning "message"
#endif
All advice is offered in good faith only. All my code is tested (unless stated explicitly otherwise) with the latest version of Microsoft Visual Studio (using the supported features of the latest standard) and is offered as examples only - not as production quality. I cannot offer advice regarding any other c/c++ compiler/IDE or incompatibilities with VS. You are ultimately responsible for the effects of your programs and the integrity of the machines they run on. Anything I post, code snippets, advice, etc is licensed as Public Domain https://creativecommons.org/publicdomain/zero/1.0/ and can be used without reference or acknowledgement. Also note that I only provide advice and guidance via the forums - and not via private messages!
C++23 Compiler: Microsoft VS2022 (17.6.5)
-
September 29th, 2021, 05:25 AM
#9
Re: #warning and MSVC
There are too many of them but I just realised that #pragma message is apparently supported by gcc - so hopefully I'll persuade the gcc programmers to use it instead of #warning
"A problem well stated is a problem half solved.” - Charles F. Kettering
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|