PDA

Click to See Complete Forum and Search --> : Pre-processor macros?


wossname
Dec 11th, 2007, 07:45 AM
Dear MS boffins:
Hypothetically speaking, how feasible do you think it would be for future versions of .net languages to have something equivalent to pre-processor macros, the likes of which are seen in C/C++?

I make extremely heavy use of them in my non-dotnet projects and my only real criticism of C#/VB is that they lack such a powerful coding aid, (otherwise it's terriffic).

I think VB and C# are similar enough to C++ now to permit such a feature, so why not?

Some reasons I thought about for not having them are as follows:
- Marketing reasons, maybe it would bring VB/C# too close to C++ to be of any benefit.
- it would screw up or slow down intellisense too much.
- Only a weirdo :wave: would want such a thing.

If it would be impractical to build it into the languages as standard, would it be something that could be implemented as an IDE plugin by a third party developer? Would the IDE bindings as they stand permit such an invasive code maniplation tool?

Discuss :)

Paul M
Dec 11th, 2007, 07:51 AM
C# does have some preprocessor directives (not 100% sure about VB.NET), nothing like C/C++ but they have them :)

wossname
Dec 11th, 2007, 07:54 AM
It's not even remotely close in terms of capability. I do use them for conditional compilation but that actually doesn't make programming any easier really, which is the sole point of prepro macros in the first place.

Paul M
Dec 11th, 2007, 08:02 AM
Yea they are a lot less capable than those in C/C++, oh and it appears VB.NET has some of the directives also.

Also i am not to sure about this but it appears you can use the C++ preprocessor if you want to on your C# files?

wossname
Dec 11th, 2007, 01:01 PM
Not sure what you mean by that. A common practice is to get a C program to use its preprocessor to generate a C# code file so you save yourself a whole lot of legwork. That is fine as far as it goes. The best use of that is where you have a large list of constants that are shared between two platforms (say unix vs. windows) and they must correlate perfectly, such things are prone to human error so macros are a great help here.

Having to rely on a separate C/C++ processor during a C# build can get quite fiddly and hard to document, hence my inquiry about this.