C# Preprocessor

  • Thread starter Thread starter Juan Manuel Formoso
  • Start date Start date
J

Juan Manuel Formoso

Hi, is there any way to determine if a class is in one project or
another with the preprocessor?

I have the class shared in sourcesafe, so it belongs to 2 projects. I
need to know before compiling where the class is so I won't compile
code that I wont need in one of the two.

#define is no good because its scope is only in the file in which it
was declare, and as I said, the class is the same in both projects...
is there a way at all?

Thanks in advance.
 
It sounds like you should refactor your code a bit instead. Why not
have one base class that contains the code common for both projects,
and then have subclasses with whatever project specific code you need?



Mattias
 
Juan Manuel Formoso said:
Hi, is there any way to determine if a class is in one project or
another with the preprocessor?

I have the class shared in sourcesafe, so it belongs to 2 projects. I
need to know before compiling where the class is so I won't compile
code that I wont need in one of the two.

#define is no good because its scope is only in the file in which it
was declare, and as I said, the class is the same in both projects...
is there a way at all?

Why not define the relevant preprocessor symbol in the project
properties, and then test it with a normal #if?
 
I didn't know that could be done...
I know we should fix our code, but that's not an option right now
since we don't have the time for it, but i'll keep it in mind

I'll use Jon suggestion.

Thank you both.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top