Re: #defines

Tech-Archive recommends: Repair Windows Errors & Optimize Windows Performance

From: Štefan Šimek (simek.blah_at_kascomp.blah.sk)
Date: 10/11/04


Date: Mon, 11 Oct 2004 15:44:02 +0200

You're right. The #define directive in C# is used for conditional
compilation only.

You should use enum's instead, for example:

[Flags]
public enum Perm
{
    Value1 = 0x00000001,
    PSSUser = 0x00000002,
    BackupUser = 0x00000004
};

The [Flags] attribute is a hint for the compiler that binary operations (&,
|, ^, ~) can be applied to the enum members.

HTH,
Stefan

"Philip" <philip@softwareforever.com> wrote in message
news:4C468FAA-0B77-4E3E-AC1B-05D8F152A40E@microsoft.com...
> From other postings I am of the impression that C# does not support
> #define
> directives for the purposes of defining bit mask definitions such as the
> following...
>
> #define val10x00000001
> #define PermPSSUser 0x00000002
> #define PermBackupUser 0x00000004
> --
> Philip



Relevant Pages

  • Re: Arm gnu directive assembler problem
    ... The names in the linker script have to match the names in the ... This is one of the ELF section stack manipulation directives. ... The optional FLAGS argument is a quoted string which may contain any ... the assembler supports another type of `.section' ...
    (comp.arch.embedded)
  • Re: /LARGEADDRESSAWARE option - can someone please post this to QualityCentral
    ... There's a full list of flags you can use here-- ... Here's the documentation for $SetPEFlags and $SetPEOptFlags from Delphi ... by these directives. ... it's not an error to place these directives in unit source ...
    (borland.public.delphi.non-technical)
  • Re: gfortran iso c bindings - capabilities
    ... but who in the industry is following the ... standard, and in what way is their usage different from Intel? ... certainly prefer to use those directives instead of fpp, ... the term "Directive Enhanced Compilation" is just ...
    (comp.lang.fortran)
  • Re: ESQL, 4GL and C/gcc on Solaris
    ... Solaris 9 doesn't come with a C compiler as standard, so I've installed gcc. ... You've got a Makefile that has flags defined in it for the Solaris C compiler and you're compiling 32 bit rather than 64 bit. ... These rules "clean up after themselves;" the corpses are removed during normal compilation. ...
    (comp.databases.informix)
  • Re: request for different compiler/run-time results
    ... with any '85 Standard compiler. ... Compilation Directives in Effect ... W Improper quote character accepted in column 30 ...
    (comp.lang.cobol)