[Mono-list] Preprocessor #define Standardization

Miguel de Icaza miguel@ximian.com
20 Aug 2001 17:19:55 -0400

> I haven't seen any guidelines on this issue, and a quick search of the code
> has found
> only one instance of their usage. I have checked the documentation and the
> C# compiler (at least Microsoft's compiler) does support accepting
> preprocessor definitions on the command line via the /define directive.

There are a number of ways of dealing with this issue.

	* Using separate source files when completely independent
	  implementations are required.

	  Consider for example the Windows.Forms, we will probably
	  have completely different versions of it depending on the
	  platform we will run. 

	* Using defines.

	  Defines look ugly and make your code look ugly, so this
	  should be used with care, and only in a few justified

	  Pretty much any piece of code like this:

#ifdef WINDOWS

	  That is just plain ugly and it grows to be horrible. 

	  It can be changed into having an `architecture' depending
	  bit and a generic bit.  So you can turn that code always

	  Blah ();

	  And then you have different implementations of Blah, see the
	  next section:

	* Using auxiliary system classes.

	  Things like path separators could be abstracted in a class
	  called System.Private.Parameters, and then classes that need
	  to use that information would retrieve that from it.  

Best wishes,