Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.c > #107759 > unrolled thread
| Started by | fl <rxjwg98@gmail.com> |
|---|---|
| First post | 2017-04-05 07:49 -0700 |
| Last post | 2017-04-06 11:38 -0400 |
| Articles | 4 — 4 participants |
Back to article view | Back to comp.lang.c
What are these functions (warning, push, disable) are in the macro definition? fl <rxjwg98@gmail.com> - 2017-04-05 07:49 -0700
Re: What are these functions (warning, push, disable) are in the macro definition? scott@slp53.sl.home (Scott Lurndal) - 2017-04-05 15:25 +0000
Re: What are these functions (warning, push, disable) are in the macro definition? Keith Thompson <kst-u@mib.org> - 2017-04-05 13:46 -0700
Re: What are these functions (warning, push, disable) are in the macro definition? Ken Brody <kenbrody@spamcop.net> - 2017-04-06 11:38 -0400
| From | fl <rxjwg98@gmail.com> |
|---|---|
| Date | 2017-04-05 07:49 -0700 |
| Subject | What are these functions (warning, push, disable) are in the macro definition? |
| Message-ID | <eaeb380d-00bf-4156-bfac-f79acc47753e@googlegroups.com> |
Hi, I have a MSVC project which has the following definitions. It builds successfully on MSVC, but I don't understand what warning, push, pop and disable are. Could you tell me that? Thanks, ......................... #if DSAS_MSVC #define DSAS_MULTILINE_MACRO_END \ __pragma( warning( push ) ) \ __pragma( warning( disable:4127 ) ) \ } \ while( 0 ) \ __pragma( warning( pop ) ) #else /* #if DSAS_MSVC */ #define DSAS_MULTILINE_MACRO_END \ } \ while ( 0 ) #endif
[toc] | [next] | [standalone]
| From | scott@slp53.sl.home (Scott Lurndal) |
|---|---|
| Date | 2017-04-05 15:25 +0000 |
| Message-ID | <u%7FA.246152$kx.176422@fx33.iad> |
| In reply to | #107759 |
fl <rxjwg98@gmail.com> writes: >Hi, > >I have a MSVC project which has the following definitions. It builds >successfully on MSVC, but I don't understand what warning, push, pop >and disable are. > >Could you tell me that? > >Thanks, > > >......................... >#if DSAS_MSVC >#define DSAS_MULTILINE_MACRO_END \ > __pragma( warning( push ) ) \ Push the current warning state on an internal compiler stack. > __pragma( warning( disable:4127 ) ) \ Disable warning 4127, whatever that is > } \ > while( 0 ) \ > __pragma( warning( pop ) ) Restore the pushed warning state. >#else /* #if DSAS_MSVC */ >#define DSAS_MULTILINE_MACRO_END \ > } \ > while ( 0 ) >#endif
[toc] | [prev] | [next] | [standalone]
| From | Keith Thompson <kst-u@mib.org> |
|---|---|
| Date | 2017-04-05 13:46 -0700 |
| Message-ID | <lnzifuzipi.fsf@kst-u.example.com> |
| In reply to | #107759 |
fl <rxjwg98@gmail.com> writes:
> I have a MSVC project which has the following definitions. It builds
> successfully on MSVC, but I don't understand what warning, push, pop
> and disable are.
[...]
>
> .........................
> #if DSAS_MSVC
> #define DSAS_MULTILINE_MACRO_END \
> __pragma( warning( push ) ) \
> __pragma( warning( disable:4127 ) ) \
> } \
> while( 0 ) \
> __pragma( warning( pop ) )
> #else /* #if DSAS_MSVC */
> #define DSAS_MULTILINE_MACRO_END \
> } \
> while ( 0 )
> #endif
This is a non-standard feature of MSVC, documented here:
https://msdn.microsoft.com/en-us/library/2c8f766e.aspx
--
Keith Thompson (The_Other_Keith) kst-u@mib.org <http://www.ghoti.net/~kst>
Working, but not speaking, for JetHead Development, Inc.
"We must do something. This is something. Therefore, we must do this."
-- Antony Jay and Jonathan Lynn, "Yes Minister"
[toc] | [prev] | [next] | [standalone]
| From | Ken Brody <kenbrody@spamcop.net> |
|---|---|
| Date | 2017-04-06 11:38 -0400 |
| Message-ID | <oc5n8b$mmk$1@dont-email.me> |
| In reply to | #107759 |
On 4/5/2017 10:49 AM, fl wrote: > Hi, > > I have a MSVC project which has the following definitions. It builds > successfully on MSVC, but I don't understand what warning, push, pop > and disable are. > > Could you tell me that? > > Thanks, > > > ......................... > #if DSAS_MSVC > #define DSAS_MULTILINE_MACRO_END \ > __pragma( warning( push ) ) \ > __pragma( warning( disable:4127 ) ) \ > } \ > while( 0 ) \ > __pragma( warning( pop ) ) > #else /* #if DSAS_MSVC */ > #define DSAS_MULTILINE_MACRO_END \ > } \ > while ( 0 ) > #endif First, all pragma statements (except for those starting with "STDC") are implementation-defined, so you would have to check with a Microsoft-related group for full details. However, since I work in MSVC, I recognize it as a basic "temporarily disable warning number 4127, and then restore it to whatever state it was before". (That's the "push" and "pop" part.) Apparently, the actual contents of the macro will generate that warning, and the author wants to tell the compiler "yes, I know, but it's all good, so shut up about it already". You can check in a Microsoft-related group, or the MSVC docs for information on what, exactly, is warning number 4127. Or, a quick web search for "msvc warning 4127" will answer it as well. -- Kenneth Brody
[toc] | [prev] | [standalone]
Back to top | Article view | comp.lang.c
csiph-web