138 questions
0
votes
1
answer
54
views
Which scope does the {$I-} directive have in Pascal?
I disable I/O checking inside a procedure:
procedure RewriteText(
FileName: string;
var TextFile: text;
var ErrMsg: string
);
begin
{$I-}
assign(TextFile, FileName);
rewrite(...
0
votes
1
answer
194
views
What is the purpose of the "HORSE_VCL" compilation directive?
I have started using the horse web framework for building an API in Delphi. The VCL sample mentions the following as a comment in the Main.Form.pas file:
// Need to set "HORSE_VCL" ...
3
votes
2
answers
207
views
Some breakpoints are disabled (gray-crossed) in Delphi debugger – why? How to enable all of them?
I’m working with Delphi and placing breakpoints (red circles on the left side of the editor near the line numbers). When I start debugging (e.g., using F4 or Run > Run to Cursor), some of the ...
3
votes
1
answer
68
views
Arduino Macros not working as expected with Classes
I want to have a macro defined in a class.
I wish to define it first in my main, but use an #ifndef to create it if the user chooses not to.
For some reason it would seem like the class is being ...
0
votes
0
answers
52
views
Using ctypes for a computation routine wrapper
For a computation demonstration project in Linux and Python env, I need to call a C multiplication routine "matmult.c" but before I want to perform an important test if I could do another ...
1
vote
0
answers
242
views
How to use SwiftData #Index with < iOS 18 compatibility
I want to use iOS 18's #Index in an app that still supports iOS 17.
This doesn't work:
@Model
final class MyModel {
if #available(iOS 18, *) {
#Index<MyModel>([\.prop1, \.prop2])
...
1
vote
1
answer
308
views
Compiler Directive to check if Skia is enabled on my Delphi FIreMonkey App?
Is there a compiler directive or some kind of directive that I can use to check in the code if Skia is enabled or not for the platform that I am compiling to?
I have a form that is used in multiple ...
1
vote
0
answers
122
views
GAS (gnu assembler) and conditional execution
Stupid question. I am writing code in pure assembly for STM32 variants. I want to make two different versions from the same source file by assembling twice with a simple change that is selectable ...
2
votes
0
answers
93
views
Delphi 11.3 compiler directives for "Development" and "Application store" modes
Please tell me the Delphi 11.3 compiler directives for development modes and the application store,
if they exist.
A switch is needed for different logic.
Development is carried out in the FireMonkey ...
0
votes
0
answers
86
views
What does the {$IFNDEF LCLTMSWEB} compiler directive mean?
I'm looking through the WEBLib.StdCtrls source code in TMS Web Core and regularly I see a {$IFNDEF LCLTMSWEB} compiler directive such as here with the TWebLabel component:
{$IFNDEF LCLTMSWEB}
[...
1
vote
1
answer
153
views
How do I add a compiler directive for TMS Web Core websites?
I can use the following compiler directive code to specify Platform specific code:
{$IFDEF MSWINDOWS}
// This code is for Windows
{$ENDIF}
{$IFDEF IOS}
// This code is for iOS
{$ENDIF}
{$IFDEF ...
1
vote
2
answers
356
views
Pass by name for macro arguments
For functions, we can use pass by name as below:
function void xyz(string x,int y);
$display(x,,y);
endfunction
initial begin
xyz(.x("Hi"),.y(2));
end
Now, I have a macro ...
0
votes
1
answer
932
views
default value for macro declaration
When a macro is created but no value is assigned, is there a default value? #define MACRO (end of line).
Macro definition has the syntax: #define <IDENTIFIER> <value>. Even if we don't ...
1
vote
1
answer
158
views
SwiftUI compiler directives trigger "Cannot infer contextual base" error for following statements
I have a SwiftUI View for a watchOS / iOS app in which I use the #if os(xxxOS) compiler directive to select between a watchOS specific View or an iOS specific View to provide the content for the the ...
0
votes
1
answer
154
views
Visual Studio C# Project Template #if DEBUG #endif disappear in produced projects
I have Visual Studio C# project template with #if DEBUG #endif directives like this:
#if DEBUG
...
#endif
But when I creating project from this template it doesn't contain this part. Can I somehow ...
2
votes
1
answer
610
views
How to assert size of `usize` to drop support for incompatible platforms?
Problem
I've just caught my self writing dynamic assertion that depends on a constant usize::MAX.
I wrote:
u128::try_from(letters.len())
.expect("No support for platform with `max pointer ...
0
votes
2
answers
291
views
Compiler directives deleted from DPR file
Question
How do I make a compiler directive stay in the DPR file?
Description
I need to turn off this compiler warning because I don't intend to make my library compatible with C++.
If I put the ...
1
vote
1
answer
1k
views
Why only include header files (.h) but not the source file (.c) in the directives?
How does the compiler know which source file is the one I am including?
Does it work as long as the name of the header and source file are the same?
For example, the header file example.h refers to ...
1
vote
0
answers
51
views
Compiler says variables declared within compiler directive doesnt exist
Suppose I have this code (all in the same class):
#if CONDITION
private static readonly string firstName = "First Name";
#endif
string GetName(){
#if CONDITION
return ...
2
votes
2
answers
747
views
How to change a .dfm property with compiler directives?
Is it possible to make a compiler directive for the .dfm properties introduced on Delphi 11 like
{$IFDEF CompilerVersion > 34.0}
PixelsPerInch = 96
{$ENDIF}
So other developers that use 10.4....
0
votes
0
answers
252
views
Local labels in emu8086
until now I have been using DOSBox and TASM to compile, link and run my 8086 code. Whenever I wanted to use local labels I would have just added LABELS @@ at the start of each code file and used @@...
0
votes
1
answer
496
views
Release build .dll still contains code that should be removed via preprocessor directives
I have a c# .net core project that is using preprocessor directives ( #if DEBUG) to enable unsafe SSL Connections during debugging. Now when I release-build the whole project and open the generated ...
1
vote
2
answers
168
views
Can someone explain hard ilogical bug on C use of #define UMAX (a, b) ((a) > (b) ? (a) : (b)) directive, that returns lower value, in 2 compilers
I'm trying to identify the reason of a bug that happens on a MUD c code base. Where the use of the #define UMAX(a, b) ((a) > (b) ? (a) : (b)) , is used to return the max of two values.
It ...
-2
votes
1
answer
914
views
What is Free Pascal Error 3208 Illegal assignment to for-loop variable [closed]
Tell me about Free Pascal compiler error 3208 "Illegal assignment to for-loop variable."
1
vote
0
answers
1k
views
How do I write test-only code in Production code using #ifdef in C++?
NOTE: I think this is quite basic, please point me in the right direction if this is already answered. I did look online but surprisingly unable to find the answer, I could be using wrong words to ...
1
vote
3
answers
137
views
Does C preprocessor directives recompute each time?
I have this line of code:
#define ALPHABET_SIZE 'z' - 'a' + 1
When I hover over ALPHABET_SIZE anywhere in my code it tells me that it expands to 'z' - 'a' + 1.
So I wondered if this expression has to ...
2
votes
0
answers
166
views
Is there a way to disregard remainder of python script file?
I am working on a refactoring a Python program. I have copied and pasted some messy source files into new Python modules and I'm working through the module top-to-bottom cleaning it up etc.
As a ...
1
vote
1
answer
133
views
Recognise #define compiler directive in fortran with ctags
I would like to configure ctags to recognize compiler directives in a fortran code. More specifically, I would like to match the following vim search result
/\v[ \t]*#define[ \t]+([-[:alnum:]*+!_:\/.?]...
1
vote
0
answers
308
views
How to create custom compile directives in swift
I have a generic function that fetches from DB objects based on a given type and filter:
class Employee: Object {
@objc dynamic var id: String = UUID().uuidString
@objc dynamic ...
1
vote
0
answers
248
views
Delphi $E directive
I am trying to automatically generate the extension of my DLLs to get FileName.$(Platform).DLL. Supposedly I can use {$E ext} to set the extension to FileName.ext, and I want FileName.ext.dll
The ...
1
vote
0
answers
38
views
How to force Visual Studio to use a specific framework version [duplicate]
I have a class library that targets multiple frameworks.
i.e.
<TargetFrameworks>netstandard2.0;netstandard2.1</TargetFrameworks>
When msbuild builds my application it correctly spits out ...
2
votes
1
answer
122
views
Visual Studio hotkey detection on run
Weird one maybe. Is there anyway to detect a hotkey combo at run-time after firing up the project in VS.
E.g. If I hold shift and press f5 or run in VS then i want to fire a special line of code.
...
2
votes
1
answer
384
views
Are there any formalized target framework directives?
I've read Microsoft's article about how to detect target framework, for example :
netcoreapp2.2
net47
net58
But there are situations where I don't care about the exact version, but the general ...
3
votes
3
answers
1k
views
Switching between compiler directives in Visual Studio 2019?
I'm using Visual Studio 2019 with SDK based project, with multiple targets:
<TargetFrameworks>netstandard2.0;net45;net46</TargetFrameworks>
But when I write conditional code, I see (...
3
votes
3
answers
4k
views
Swift errors using #if, #endif
Using #if, #endif in Swift (using Xcode) produces errors if it cuts into the flow of an operation. This screenshot says it all:
Does anyone know a solution to make this example work, without repeating ...
8
votes
1
answer
2k
views
What does the phrase {$R *.dfm} mean in the code editor?
What does the phrase {$R *.dfm} mean in the code editor?
I have tried this:
//{$R *.dfm}
-1
votes
1
answer
133
views
Which program in the compiler takes care of the preprocessors? [closed]
Compiler is a combination of many programs. So which program takes care of which part during compilation? I read somewhere that the preprocessor program takes care of the C preprocessor directives(...
7
votes
1
answer
7k
views
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=" ,") # ...
4
votes
1
answer
123
views
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 ...
4
votes
1
answer
1k
views
How __future__ imports work under the hood
I've been fascinated by the __future__ module - in particular, its ability to change the way statements are parsed in python.
What's most interesting is how doing something like
from __future__ ...
0
votes
0
answers
363
views
Why does MSBuild mark #Disable and #Enable directives as Error BC30248?
I'm working in an environment in which all projects are placed into a Global Solution irrelevant of the specific business areas of the projects. So the solution is a monstrosity. I'm accustomed to a ...
3
votes
2
answers
155
views
Can I deduce the type of a type in a compiler directive
Is it possible to create a conditional define like so:
{$if typeof(TNode) = record}
type PNode = ^TNode;
{$else}
type PNode = TNode;
{$end}
Why do I want this?
I'm alternating between using class and ...
3
votes
2
answers
3k
views
Silencing Unused Static Function Warnings for a Section of Code
In the spirit of What are the consequences of ignoring: warning: unused parameter, but I have static functions that are unused,
#include <stdlib.h> /* EXIT_SUCCESS */
#include <stdio.h> /...
2
votes
1
answer
145
views
How to follow preprocessor directives throughout a compilation
I'm working with a program, full of compiler directives, programmed in Visual Studio.
I've made some changes and now I'm stuck with an unresolved external compiler/linker error.
I believe this is ...
0
votes
1
answer
2k
views
Non-specific `include file name - System Verilog compiler directives
I want to use the `include directive to call upon a non-specific file name. For example,
there is this file name "name_defines.svh" in some other directory. Since the "name" of "name_defines.svh" ...
1
vote
0
answers
376
views
gfortran compiler directive to add/remove compiler option
I would like to temporarily disable a gfortran compiler option for a piece of Fortran code. I am looking for something like:
!GFORTRAN$ PUSH_OPTION(-fcheck=bounds)
SUBROUTINE FOO(BAR)
INTEGER BAR(...
0
votes
1
answer
89
views
Using compiler directive to warn if a file is missing
I have a file that is included on the bundle that has the following name:
databaseX.sqlite
where X is the app's version. If the version is 2.8, the file should be named database2.8.sqlite. I have to ...
1
vote
2
answers
234
views
What is the conditional compiler directive binded to Delphi XE4 compiler?
What is the conditional compiler directive binded to Delphi XE4 compiler?
I though something like this:
{$ifdef VerDXE4}
code segment compiled only by the Delphi XE4 compiler
{$endif}
1
vote
1
answer
2k
views
C++ #define value not being read in cpp file
In my C++ .h file:
class foo {
#define useThis true
...
}
In my .cpp file:
#if useThis
... generate A code
#else
... generate B code
#endif
The problem is that the #define values are not being read ...
0
votes
2
answers
2k
views
Workaround for systemverilog there is no `if compiler directive
In systemverilog there is no `if compiler directive. So the following lines are incorrect:
`define BITS 16
reg[`BITS-1:0] my_reg;
...
`if `BITS > 10
my_reg[31] = 1'b0;
endif
...
Without `if ...