By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
445,645 Members | 1,048 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 445,645 IT Pros & Developers. It's quick & easy.

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

P: n/a
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
Share this Question
Share on Google+
7 Replies


P: n/a
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

P: n/a
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

P: n/a
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

P: n/a
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

P: n/a
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

P: n/a
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

P: n/a
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.