473,378 Members | 1,544 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,378 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 2311
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...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 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 former...
0
by: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...

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.