470,641 Members | 1,578 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 470,641 developers. It's quick & easy.

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 2135
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 discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

3 posts views Thread by Robert W. | last post: by
5 posts views Thread by Trapulo | last post: by
5 posts views Thread by Torben Laursen | last post: by
1 post views Thread by kalaivanan | last post: by
3 posts views Thread by naunetr | last post: by
5 posts views Thread by Torben Laursen | last post: by
29 posts views Thread by pereges | last post: by
???
1 post views Thread by Stoney L | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.