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
7
votes
4 answers

Is it possible to ensure copy elision?

Copy elision is a neat optimization technique and in some cases relying on copy elision can actually be faster than passing around references "by hand". So, let's assume you have identified a critical code path where you rely on the fact that the…
Martin Ba
  • 37,187
  • 33
  • 183
  • 337
7
votes
1 answer

Cython compiler directive language_level not respected

I am working with compiler directives for Cython (http://docs.cython.org/en/latest/src/reference/compilation.html#globally). $ cat temp.pyx # cython: language_level=3 print("abc", "def", sep=" ,") # invalid in python 2 Compiling: $ cythonize -i…
Saim Raza
  • 1,420
  • 13
  • 16
7
votes
6 answers

#Define Compiler Directive in C#

In C, I could declare a compiler directive as follows: #define MY_NUMBER 10 However, in C#, I only appear to be able to do this: #define MY_NUMBER Which is obviously useless in this case. Is this correct, or am I doing something wrong? If not,…
Paul Michaels
  • 16,185
  • 43
  • 146
  • 269
7
votes
3 answers

Scala: Code only run when debugging(#ifdef equivalent?)

In C++ I can write: #ifdef DEBUG cout << "Debugging!" << endl; Is there any equivalent in Scala?
Lai Yu-Hsuan
  • 27,509
  • 28
  • 97
  • 164
7
votes
3 answers

How can I tell at compile time whether the project is a program or a library?

I'm trying to know if the project is a library or not, after read the help I wrote this code that does not work: {$IF DEFINED(LIBPREFIX)} {$DEFINE PROJECT_IS_EXECUTABLE} {$UNDEF PROJECT_IS_LIBRARY} {$ELSE} {$DEFINE…
Cesar Romero
  • 4,027
  • 1
  • 25
  • 44
6
votes
4 answers

Getting rid of precompiler directives in C#

I've been asked to maintain some not-as-legacy-as-I-would-like code, and it is riddled with compiler directives, making it pretty much unreadable and almost as maintainable. Case in point: #if CONDITION_1 protected override void…
Sergi Papaseit
  • 15,999
  • 16
  • 67
  • 101
6
votes
1 answer

Monotouch Compiler Directive if debug

In my MonoTouch app, how can I put in a # compiler directive to include code only if in debug mode?
Ian Vink
  • 66,960
  • 104
  • 341
  • 555
6
votes
3 answers

Add unit to project is removing a compiler directive from the project source

Should this work this way or am I doing something wrong? I have this code in my project source: {$IFDEF DEBUG} ADebugUnit, {$ELSE} ARelaseUnit, {$ENDIF} I want ADebugUnit to be used when in debug mode but AReleaseUnit to be used when…
Ann Gossard
  • 123
  • 8
6
votes
3 answers

How to tell if code is running locally from Visual Studio/Cassini

I have an interface, let's call it ILocateLogFile, with a standard implementation for dev/beta/production servers, and one that only works in the local development environment. I can't seem to think of a nice clean way to decide (preferably at…
McGarnagle
  • 101,349
  • 31
  • 229
  • 260
5
votes
1 answer

Delphi compiler directive for shortstrings not working?

I'm trying to port a project from Delphi 4 to Delphi XE2. I have a requirement to use shortstring in the project. According to the Delphi Help, $H- should make the compiler use shortstrings for the string type. I've used this directive but I don't…
Maria
  • 5,574
  • 1
  • 29
  • 39
5
votes
2 answers

Commenting standards while writing iOS applications?

G'Day Programmers, I am from Java background however I have just started learning C++ and Objective C. I was worried when I so lots of different coding style in third party Objective C code. But I am kind a stuck with a dilemma. My dilemma is…
TeaCupApp
  • 11,316
  • 18
  • 70
  • 150
5
votes
1 answer

Is compiler directive WIN32 and CPUX86, WIN64 and CPUX64 interchangeable in Delphi?

Is compiler directive WIN32 and CPUX86, WIN64 and CPUX64 interchangeable in Delphi? If yes, Which one is preferred? If no, why?
justyy
  • 5,831
  • 4
  • 40
  • 73
5
votes
4 answers

Delphi Compiler Directive to Evaluate Arguments in Reverse

I was really impressed with this delphi two liner using the IFThen function from Math.pas. However, it evaluates the DB.ReturnFieldI first, which is unfortunate because I need to call DB.first to get the first record. DB.RunQuery('select…
Peter Turner
  • 11,199
  • 10
  • 68
  • 109
4
votes
2 answers

Can one have conditional code at runtime based on the CPU architecture?

I'm using .Net 4.5 (preview... 4 is fine for the purposes of this question). I'm doing threading work. Based on my studies, I know that x86 CPUs have a strong memory model, which means writes won't be reordered. This makes releasing locks safe. This…
IamIC
  • 17,747
  • 20
  • 91
  • 154
4
votes
1 answer

Equivalent of c\c++ compiler directives in Julia

using compiler directives like #if A some instructions #elseif B some instructions #end In C\C++ language, one can tell the compiler to ignore some parts of code under some conditions. I`m curious about to know if there is an equivalent of this…
1
2
3
8 9