472,784 Members | 894 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

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

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 2265
You can mark classes, method properties etc with the Conditional attribute:

[Conditional("DEBUG")]

Or, you can use #define Whatever

HTH,

Bill
"John Dolinka" <jr*********@cdc.gov> wrote in message
news:Oy**************@TK2MSFTNGP11.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("DEBUG")]

Or, you can use #define Whatever

HTH,

Bill
"John Dolinka" <jr*********@cdc.gov> wrote in message
news:Oy**************@TK2MSFTNGP11.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********@comcast.nospam.net> wrote in message
news:uG**************@tk2msftngp13.phx.gbl...
You can mark classes, method properties etc with the Conditional attribute:
[Conditional("DEBUG")]

Or, you can use #define Whatever

HTH,

Bill
"John Dolinka" <jr*********@cdc.gov> wrote in message
news:Oy**************@TK2MSFTNGP11.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********@comcast.nospam.net> wrote in message
news:uG**************@tk2msftngp13.phx.gbl...
You can mark classes, method properties etc with the Conditional attribute:
[Conditional("DEBUG")]

Or, you can use #define Whatever

HTH,

Bill
"John Dolinka" <jr*********@cdc.gov> wrote in message
news:Oy**************@TK2MSFTNGP11.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*********@cdc.gov> wrote in message
news:eX**************@tk2msftngp13.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********@comcast.nospam.net> wrote in message
news:uG**************@tk2msftngp13.phx.gbl...
You can mark classes, method properties etc with the Conditional

attribute:

[Conditional("DEBUG")]

Or, you can use #define Whatever

HTH,

Bill
"John Dolinka" <jr*********@cdc.gov> wrote in message
news:Oy**************@TK2MSFTNGP11.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*********@cdc.gov> wrote in message
news:eX**************@tk2msftngp13.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********@comcast.nospam.net> wrote in message
news:uG**************@tk2msftngp13.phx.gbl...
You can mark classes, method properties etc with the Conditional

attribute:

[Conditional("DEBUG")]

Or, you can use #define Whatever

HTH,

Bill
"John Dolinka" <jr*********@cdc.gov> wrote in message
news:Oy**************@TK2MSFTNGP11.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******@hotmail.com> wrote in message
news:03******************************@news.meganet news.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*********@cdc.gov> wrote in message
news:eX**************@tk2msftngp13.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********@comcast.nospam.net> wrote in message
news:uG**************@tk2msftngp13.phx.gbl...
You can mark classes, method properties etc with the Conditional

attribute:

[Conditional("DEBUG")]

Or, you can use #define Whatever

HTH,

Bill
"John Dolinka" <jr*********@cdc.gov> wrote in message
news:Oy**************@TK2MSFTNGP11.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
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...
3
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...
3
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...
5
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...
5
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...
1
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...
3
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:...
5
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...
29
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...
0
by: erikbower65 | last post by:
Using CodiumAI's pr-agent is simple and powerful. Follow these steps: 1. Install CodiumAI CLI: Ensure Node.js is installed, then run 'npm install -g codiumai' in the terminal. 2. Connect to...
0
linyimin
by: linyimin | last post by:
Spring Startup Analyzer generates an interactive Spring application startup report that lets you understand what contributes to the application startup time and helps to optimize it. Support for...
0
by: erikbower65 | last post by:
Here's a concise step-by-step guide for manually installing IntelliJ IDEA: 1. Download: Visit the official JetBrains website and download the IntelliJ IDEA Community or Ultimate edition based on...
0
by: Taofi | last post by:
I try to insert a new record but the error message says the number of query names and destination fields are not the same This are my field names ID, Budgeted, Actual, Status and Differences ...
14
DJRhino1175
by: DJRhino1175 | last post by:
When I run this code I get an error, its Run-time error# 424 Object required...This is my first attempt at doing something like this. I test the entire code and it worked until I added this - If...
5
by: DJRhino | last post by:
Private Sub CboDrawingID_BeforeUpdate(Cancel As Integer) If = 310029923 Or 310030138 Or 310030152 Or 310030346 Or 310030348 Or _ 310030356 Or 310030359 Or 310030362 Or...
0
by: lllomh | last post by:
Define the method first this.state = { buttonBackgroundColor: 'green', isBlinking: false, // A new status is added to identify whether the button is blinking or not } autoStart=()=>{
0
by: Mushico | last post by:
How to calculate date of retirement from date of birth
2
by: DJRhino | last post by:
Was curious if anyone else was having this same issue or not.... I was just Up/Down graded to windows 11 and now my access combo boxes are not acting right. With win 10 I could start typing...

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.