Questions tagged [compiler-directives]

Compiler directive is a language construct that specifies how a compiler (or assembler or interpreter) should process its input.

Compiler directive is a language construct that specifies how a compiler (or assembler or interpreter) should process its input.

125 questions
539
votes
15 answers

C# if/then directives for debug vs release

In Solution properties, I have Configuration set to "release" for my one and only project. At the beginning of the main routine, I have this code, and it is showing "Mode=Debug". I also have these two lines at the very top: #define DEBUG #define…
NealWalters
  • 17,197
  • 42
  • 141
  • 251
31
votes
3 answers

Conditional compile when running in Simulator as opposed to on a device

Is there a compiler directive I can use to compile a different line of code when targetting the simulator as opposed to my device. Something like: # IF SIMULATOR [self.imagePicker setSourceType:UIImagePickerControllerSourceTypePhotoLibrary]; #…
Codebeef
  • 43,508
  • 23
  • 86
  • 119
27
votes
1 answer

How to set project wide #define in C#

I have several classes in a project which need to only be in certain builds of the application which are currently not ready for release or debug. To prevent these classes from being used, I want to set around them this: #if USE_MYCLASS // Code…
Brett Allen
  • 5,297
  • 5
  • 32
  • 62
23
votes
4 answers

Delphi #IF(DEBUG) equivalent?

Is there a Delphi equivalent of the C# #if(DEBUG) compiler directive?
Boris Callens
  • 90,659
  • 85
  • 207
  • 305
20
votes
4 answers

How do I test for compiler directives with an MSBuild Condition in a .csproj file?

I am totally new to the functions and conditions in .csproj files so any and all help is appreciated. What I want to do is check for a specific compiler directive in the current configuration. An example would be something like the…
Mike Webb
  • 8,855
  • 18
  • 78
  • 111
15
votes
5 answers

Where do I define symbols tested with {$IFDEF}?

When I use Delphi directives in code, like: {$IFDEF something} . . . {$ENDIF} Where do I assign the word 'something' in the project? I tried in some places in project options but it didn't work. Guess I didn't find the correct one.
dzibul
  • 612
  • 2
  • 7
  • 20
14
votes
1 answer

How to conditionally reference a DLL based on a compilation symbol?

Visual Studio 2013. I have an external DLL which I am referencing like this in the csproj file: Path\To\Dll\NameOfDll.dll I want this reference to…
cja
  • 9,512
  • 21
  • 75
  • 129
13
votes
1 answer

{$WARN SYMBOL_PLATFORM OFF} does not turn off warnings

I have this piece of code: INTERFACE {$WARN SYMBOL_PLATFORM OFF} USES Winapi.Windows, etc, {$IFDEF MSWINDOWS}Vcl.FileCtrl, {$ENDIF} System.IniFiles; {$WARN SYMBOL_PLATFORM ON} The compiler shows: [dcc32 Warning] W1005 Unit 'Vcl.FileCtrl' is …
Gabriel
  • 20,797
  • 27
  • 159
  • 293
12
votes
2 answers

Compiler Directives - Delphi Versions

I have a unit I wrote in Delphi 7 some time ago, and have just had the fun (pain) of converting to Delphi XE (Unicode). The Unit works fine after some trouble, I am now trying to make this unit compatible with different Delphi Versions should I ever…
user741875
12
votes
3 answers

How can I temporarily disable the "return value might be undefined" warning?

I want to disable a specific warning (W1035) in my code, since I think that the compiler is wrong about this warning: function TfrmNagScreen.Run: TOption; begin if ShowModal = mrOk then Result := TOption(rdgAction.EditValue) else …
Jens Mühlenhoff
  • 14,565
  • 6
  • 56
  • 113
9
votes
4 answers

C# Compiler Directives

I’m looking at some C# code, and have come across the following statement: #if DEBUG // Do something here #else // Do something else #endif I assumed that DEBUG would be a defined somewhere as follows: #define DEBUG But I’m unable to find…
Paul Michaels
  • 16,185
  • 43
  • 146
  • 269
8
votes
2 answers

#warning directive in VB.net

I know the #warning directive does not exist in vb.net... is there anything like it? I want to be able to throw messages (warnings) at compiler time.
sebagomez
  • 9,501
  • 7
  • 51
  • 89
8
votes
3 answers

How are Perl's lexically-scoped pragmas implemented?

Pragmas, like autodie, according to the docs, are lexically scoped. { use autodie; .. .. } # Can die here Does this apply to all modules loaded with use? As far as I know, use is almost the same as: BEGIN { require autodie; …
snoofkin
  • 8,725
  • 14
  • 49
  • 86
8
votes
1 answer

MonoTouch compiler directive for iPhone Simulator

Does anyone know the compiler directive I'd use in MonoTouch to see if I'm running in the iPhone simulator? Can't find any info anywhere. Thanks!
SomaMan
  • 4,127
  • 1
  • 34
  • 45
7
votes
2 answers

What is the meaning of {$C PRELOAD} directive?

I found this directive declared in Controls.pas (and also in other units) and I'll be glad to know what does it mean. {$C PRELOAD} As far as I know $C means assertions control but what is the PRELOAD keyword ? Is it something like "assert me at…
Martin Reiner
  • 2,167
  • 2
  • 20
  • 34
1
2 3
8 9