473,385 Members | 1,468 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,385 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 6543
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: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...
0
by: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
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: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
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...

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.