473,583 Members | 3,072 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Conditional compile from a main file with defines, is it possible?

I have a project of several files with #defines to setup a conditional
compile. I would like to put these #defines in a single file and change the
conditional compile from this one file with the #defines using an "include
like" directive.

C# does not have a #include directive so it appears that I can not do this.
Am I missing something? Is it possible to do this in c#.

Thanks,

John Dolinka.
Nov 15 '05 #1
7 2325
You can mark classes, method properties etc with the Conditional attribute:

[Conditional("DE BUG")]

Or, you can use #define Whatever

HTH,

Bill
"John Dolinka" <jr*********@cd c.gov> wrote in message
news:Oy******** ******@TK2MSFTN GP11.phx.gbl...
I have a project of several files with #defines to setup a conditional
compile. I would like to put these #defines in a single file and change the conditional compile from this one file with the #defines using an "include
like" directive.

C# does not have a #include directive so it appears that I can not do this. Am I missing something? Is it possible to do this in c#.

Thanks,

John Dolinka.

Nov 15 '05 #2
You can mark classes, method properties etc with the Conditional attribute:

[Conditional("DE BUG")]

Or, you can use #define Whatever

HTH,

Bill
"John Dolinka" <jr*********@cd c.gov> wrote in message
news:Oy******** ******@TK2MSFTN GP11.phx.gbl...
I have a project of several files with #defines to setup a conditional
compile. I would like to put these #defines in a single file and change the conditional compile from this one file with the #defines using an "include
like" directive.

C# does not have a #include directive so it appears that I can not do this. Am I missing something? Is it possible to do this in c#.

Thanks,

John Dolinka.

Nov 15 '05 #3
Yes, but I have several cs files affected by the conditional compile. I
want to control the conditional compile from a single file. The problem is
the #define directive has to be the first "token" of any cs file, and there
is no provision for grouping defines across a project in a single file (at
least not that I am aware of).
Thanks for your response.

"William Ryan [eMVP]" <do********@com cast.nospam.net > wrote in message
news:uG******** ******@tk2msftn gp13.phx.gbl...
You can mark classes, method properties etc with the Conditional attribute:
[Conditional("DE BUG")]

Or, you can use #define Whatever

HTH,

Bill
"John Dolinka" <jr*********@cd c.gov> wrote in message
news:Oy******** ******@TK2MSFTN GP11.phx.gbl...
I have a project of several files with #defines to setup a conditional
compile. I would like to put these #defines in a single file and change

the
conditional compile from this one file with the #defines using an "include like" directive.

C# does not have a #include directive so it appears that I can not do

this.
Am I missing something? Is it possible to do this in c#.

Thanks,

John Dolinka.


Nov 15 '05 #4
Yes, but I have several cs files affected by the conditional compile. I
want to control the conditional compile from a single file. The problem is
the #define directive has to be the first "token" of any cs file, and there
is no provision for grouping defines across a project in a single file (at
least not that I am aware of).
Thanks for your response.

"William Ryan [eMVP]" <do********@com cast.nospam.net > wrote in message
news:uG******** ******@tk2msftn gp13.phx.gbl...
You can mark classes, method properties etc with the Conditional attribute:
[Conditional("DE BUG")]

Or, you can use #define Whatever

HTH,

Bill
"John Dolinka" <jr*********@cd c.gov> wrote in message
news:Oy******** ******@TK2MSFTN GP11.phx.gbl...
I have a project of several files with #defines to setup a conditional
compile. I would like to put these #defines in a single file and change

the
conditional compile from this one file with the #defines using an "include like" directive.

C# does not have a #include directive so it appears that I can not do

this.
Am I missing something? Is it possible to do this in c#.

Thanks,

John Dolinka.


Nov 15 '05 #5
Right-click on the project and select properties. Select Configuration
Properties and the first property is Conditional Compilation Constants.

This is where you define them in C#.

Pete
--
http://www.petedavis.net

"John Dolinka" <jr*********@cd c.gov> wrote in message
news:eX******** ******@tk2msftn gp13.phx.gbl...
Yes, but I have several cs files affected by the conditional compile. I
want to control the conditional compile from a single file. The problem is the #define directive has to be the first "token" of any cs file, and there is no provision for grouping defines across a project in a single file (at
least not that I am aware of).
Thanks for your response.

"William Ryan [eMVP]" <do********@com cast.nospam.net > wrote in message
news:uG******** ******@tk2msftn gp13.phx.gbl...
You can mark classes, method properties etc with the Conditional

attribute:

[Conditional("DE BUG")]

Or, you can use #define Whatever

HTH,

Bill
"John Dolinka" <jr*********@cd c.gov> wrote in message
news:Oy******** ******@TK2MSFTN GP11.phx.gbl...
I have a project of several files with #defines to setup a conditional
compile. I would like to put these #defines in a single file and
change
the
conditional compile from this one file with the #defines using an

"include like" directive.

C# does not have a #include directive so it appears that I can not do

this.
Am I missing something? Is it possible to do this in c#.

Thanks,

John Dolinka.



Nov 15 '05 #6
Right-click on the project and select properties. Select Configuration
Properties and the first property is Conditional Compilation Constants.

This is where you define them in C#.

Pete
--
http://www.petedavis.net

"John Dolinka" <jr*********@cd c.gov> wrote in message
news:eX******** ******@tk2msftn gp13.phx.gbl...
Yes, but I have several cs files affected by the conditional compile. I
want to control the conditional compile from a single file. The problem is the #define directive has to be the first "token" of any cs file, and there is no provision for grouping defines across a project in a single file (at
least not that I am aware of).
Thanks for your response.

"William Ryan [eMVP]" <do********@com cast.nospam.net > wrote in message
news:uG******** ******@tk2msftn gp13.phx.gbl...
You can mark classes, method properties etc with the Conditional

attribute:

[Conditional("DE BUG")]

Or, you can use #define Whatever

HTH,

Bill
"John Dolinka" <jr*********@cd c.gov> wrote in message
news:Oy******** ******@TK2MSFTN GP11.phx.gbl...
I have a project of several files with #defines to setup a conditional
compile. I would like to put these #defines in a single file and
change
the
conditional compile from this one file with the #defines using an

"include like" directive.

C# does not have a #include directive so it appears that I can not do

this.
Am I missing something? Is it possible to do this in c#.

Thanks,

John Dolinka.



Nov 15 '05 #7
Thanks! That did the trick.

"Pete Davis" <pd******@hotma il.com> wrote in message
news:03******** *************** *******@news.me ganetnews.com.. .
Right-click on the project and select properties. Select Configuration
Properties and the first property is Conditional Compilation Constants.

This is where you define them in C#.

Pete
--
http://www.petedavis.net

"John Dolinka" <jr*********@cd c.gov> wrote in message
news:eX******** ******@tk2msftn gp13.phx.gbl...
Yes, but I have several cs files affected by the conditional compile. I
want to control the conditional compile from a single file. The problem

is
the #define directive has to be the first "token" of any cs file, and

there
is no provision for grouping defines across a project in a single file (at
least not that I am aware of).
Thanks for your response.

"William Ryan [eMVP]" <do********@com cast.nospam.net > wrote in message
news:uG******** ******@tk2msftn gp13.phx.gbl...
You can mark classes, method properties etc with the Conditional

attribute:

[Conditional("DE BUG")]

Or, you can use #define Whatever

HTH,

Bill
"John Dolinka" <jr*********@cd c.gov> wrote in message
news:Oy******** ******@TK2MSFTN GP11.phx.gbl...
> I have a project of several files with #defines to setup a conditional > compile. I would like to put these #defines in a single file and

change the
> conditional compile from this one file with the #defines using an

"include
> like" directive.
>
>
>
> C# does not have a #include directive so it appears that I can not do this.
> Am I missing something? Is it possible to do this in c#.
>
>
>
> Thanks,
>
>
>
> John Dolinka.
>
>



Nov 15 '05 #8

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

Similar topics

0
302
by: John Dolinka | last post by:
I have a project of several files with #defines to setup a conditional compile. I would like to put these #defines in a single file and change the conditional compile from this one file with the #defines using an "include like" directive. C# does not have a #include directive so it appears that I can not do this. Am I missing...
3
1299
by: Robert W. | last post by:
I have a library that I'd like to have both a WinForms app and a CF app utilize. Generally the code is very compatible but sometimes there are some differences. At first I thought I could use conditional statements like #if (POCKETPC), #else, and #endif to differentiate different code constructs but then I learned that these only take...
3
6029
by: SStory | last post by:
I would like to have some code compile if my Active Configuration is set to debug and not compile if it is set to Release. I don't want to have to remember to define a constant. I just want to change configurations and all debug code not execute. How is this possible. Thanks in advance,
5
7970
by: Trapulo | last post by:
I'm using conditonal compile with statement #IF CONFIG This works if I use #IF CONFIG = "Debug" or #IF CONFIG= "Release" But if I define an other compilation profile, eg. "BestRelease", and I use #IF CONFIG = "BestRelease", compiler doesn't recognize the true condition and doesn't compile statements inside #IF... #END IF block. Is this a...
5
1516
by: Torben Laursen | last post by:
Hi Often I just want to compile one c++ file in a project the check it for errors. Now I can right click on a *.cpp file and select "Compile" But is there a way and short cut to compile a file of any type. luke *.cc, *.h, *hpp Thanks Torben
1
1695
by: kalaivanan | last post by:
hi, how should i compile csharp programs in the cmd command prompt without being installing visual studio .net. I have installed framework 1.1 and sdk. also i have executed the vsvars32 btach file. still iam not able to compile the csharp file. the error generated is: csc is not recognized as internal or external command. But in another...
3
3270
by: naunetr | last post by:
hello all, i wrote the small program below to practice conditional compiling. if i define MYSYMBOL then everthing works fine, but when i comment MYSYMBOL gcc gives the following message: cnd_compile01.c:4:2: error: #error "Error" cnd_compile01.c:1: warning: ISO C forbids an empty source file i cant understand the warning and how to...
5
1204
by: Torben Laursen | last post by:
Hi Is it possible to write a macro that compiles a file set (cpp/h). I can find it on the menu if I right click on a cpp file but it would be nice to just have a macro that I could call using a shortcut. Can anyone show me what that macro should look like? Thanks Torben
29
2021
by: pereges | last post by:
By main file, I mean the one which contains the main routine. Can some one please provide suggestions as to how I can improve the organization of main file ? I have just though about a rough skeleton. In my ray tracing project, I have to carry out following task (in sequence) 1. Read the mesh from an ascii file and store it in the mesh...
0
8182
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. ...
1
7935
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For...
0
8193
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the...
0
6579
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then...
1
5701
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 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 a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes...
0
3818
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in...
1
2333
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
1
1433
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
1157
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating...

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.