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

  • Thread starter Thread starter John Dolinka
  • Start date Start date
J

John Dolinka

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

[Conditional("DEBUG")]

Or, you can use #define Whatever

HTH,

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

[Conditional("DEBUG")]

Or, you can use #define Whatever

HTH,

Bill
John Dolinka said:
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.
 
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 said:
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 said:
You can mark classes, method properties etc with the Conditional attribute:

[Conditional("DEBUG")]

Or, you can use #define Whatever

HTH,

Bill
John Dolinka said:
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.
 
Thanks! That did the trick.

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

[Conditional("DEBUG")]

Or, you can use #define Whatever

HTH,

Bill
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.
 
Back
Top