473,387 Members | 1,882 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,387 software developers and data experts.

#define together with #pragma

Hi,

I just wanted to write a quick macro, which will wrap the following
code

#define EXCLUDE_WIN_WARNING(warning_id) \
#ifdef _MSC_VER \
#pragma warning(push) \
#pragma warning(disable, warning_id) \
#endif
#define RESTORE_WIN_WARNING \
#ifdef _MSC_VER \
#pragma warning(pop) \
#endif
This does not compile at all. The problem in this case is the # sign.
I would like to use it in the following way:

EXCLUDE_WIN_WARNING(3456)
#include <third_party_header.h>
RESTORE_WIN_WARNING

Can somone tell me how to tho this? It is probably something silly I
forget but I am having problems with compilation.

Thanks a lot for help,

Pshemek

Oct 27 '06 #1
1 6544
pr**************@gazeta.pl wrote:
Hi,

I just wanted to write a quick macro, which will wrap the following
code

#define EXCLUDE_WIN_WARNING(warning_id) \
#ifdef _MSC_VER \
#pragma warning(push) \
#pragma warning(disable, warning_id) \
#endif
#define RESTORE_WIN_WARNING \
#ifdef _MSC_VER \
#pragma warning(pop) \
#endif
This does not compile at all. The problem in this case is the # sign.
You can't have a preprocessor directive as the result of macro
expansion.

I would like to use it in the following way:

EXCLUDE_WIN_WARNING(3456)
#include <third_party_header.h>
RESTORE_WIN_WARNING

Can somone tell me how to tho this? It is probably something silly I
forget but I am having problems with compilation.
Place the directives in a separate file and #include the file.

Regards,
Bart.

Oct 27 '06 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

19
by: Robert | last post by:
Greetings everyone, I was wondering if a const variable or object took up space. I know that a #define'd macro doesn't, as it's basically just interpreted by the compiler. If a const does take...
3
by: xudeutsch | last post by:
I have such a block in C++ #pragma pack(push,4) #define STATE_NULL 0x0000 #pragma pack(pop) and I need to convert it to C#. I want to use the "MarshalAs" attribute, but i dont know which...
4
by: xudeutsch | last post by:
thanks, Nicholas and cody. but as far as i know, the following directive " #pragma pack(push,4)" will ensure that: when the data are transferred through networks to other platforms, the const...
1
by: Gustavo L. Fabro | last post by:
Greetings! Going directly to the point: myclass.h: //-------------------------------------- #pragma managed //Forward declaration
1
by: seyong_choi | last post by:
I want to write a library that has a defined function (special_subroutine in this example) aliased different names (special_subroutine_1 and special_subroutine_2 in this example). i.e., I need to...
0
by: przemyslaw.sliwa | last post by:
Hi, I just wanted to write a quick macro, which will wrap the following code #define EXCLUDE_WIN_WARNING(warning_id) \ #ifdef _MSC_VER \ #pragma warning(push) \...
7
by: aaragon | last post by:
Hi everyone, I have a simple question. I'm trying to make a macro in one file so I can use it in main.cpp. The idea is that I the user of my code has simple to type the macro definition to replace...
26
by: Rick | last post by:
I'm told that "#pragma once" has made it into the ISO standard for either C or C++. I can't find any reference to that anywhere. If it's true, do any of you have a reference I can use? ...
0
debasisdas
by: debasisdas | last post by:
PRAGMA:-Signifies that the statement is a pragma (compiler directive). Pragmas are processed at compile time, not at run time. They pass information to the compiler. A pragma is an instruction to...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.