compiler-directives

#warning directive in VB.net

老子叫甜甜 提交于 2020-01-23 05:31:10
问题 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. 回答1: As far as I've ever been able to find... no. 回答2: It's not the same as preprocessor warning, but in the most cases where I need a warning for the user I generate one using the ObsoleteAttribute: <ObsoleteAttribute("You should no used this method!", False)> Sub MySub() End Sub However, since it is not the same as a preprocessor warning it

Is it possible to ensure copy elision?

大城市里の小女人 提交于 2020-01-11 08:33:09
问题 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 copy elision is performed by your compiler for the code path for maximum performance. But now you are relying on a compiler optimization. Is there any (compiler specific, obviously) way to ensure that the copy elision is actually performed and have

Delphi Compiler Directive to Evaluate Arguments in Reverse

情到浓时终转凉″ 提交于 2019-12-30 09:36:38
问题 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 awesomedata1 from awesometable where awesometableid = "great"'); result := IfThen(DB.First = 0, DB.ReturnFieldI('awesomedata1')); (as a pointless clarification, because I've got so many good answers already. I forgot to mention that 0 is the code that DB

CLIPS constant compiler directive

≯℡__Kan透↙ 提交于 2019-12-25 00:37:52
问题 Similar to the compiler directive for constants in C, is there a way I can do the following in CLIPS? #define INFINITY 1000000000 (deftemplate foo (slot num (type INTEGER) (default INFINITY)) ) ... (defrule bar (foo (num INFINITY)) => ... ) 回答1: You can define a global variable and treat it as a constant: CLIPS> (defglobal ?*INFINITY* = 1000000000) CLIPS> (deftemplate foo (slot num (type INTEGER) (default ?*INFINITY*))) CLIPS> (defrule bar (foo (num ?num&:(eq ?num ?*INFINITY*))) =>) CLIPS>

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

你。 提交于 2019-12-18 11:52:34
问题 Visual Studio 2013. I have an external DLL which I am referencing like this in the csproj file: <ItemGroup> <Reference Include="NameOfDll"> <HintPath>Path\To\Dll\NameOfDll.dll</HintPath> </Reference> I want this reference to function when a compiler symbol exists and to not function when that compiler symbol does not exist. (To address the first comment, below, let's say the compiler symbol is called Fred.) This question [ Conditional Reference ] made me think I could add an attribute called

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

笑着哭i 提交于 2019-12-18 11:52:14
问题 Visual Studio 2013. I have an external DLL which I am referencing like this in the csproj file: <ItemGroup> <Reference Include="NameOfDll"> <HintPath>Path\To\Dll\NameOfDll.dll</HintPath> </Reference> I want this reference to function when a compiler symbol exists and to not function when that compiler symbol does not exist. (To address the first comment, below, let's say the compiler symbol is called Fred.) This question [ Conditional Reference ] made me think I could add an attribute called

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

扶醉桌前 提交于 2019-12-13 11:55:40
问题 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 Abort end; There is no way the result could be undefined, since Abort throws EAbort . I tried: {$WARN 1035 Off} : Apparently this only works for some specific errors (see Documentation) {$W-1035} : Does nothing at all I know I can switch off the warning globally in

Omitting code: Any difference between Conditional Attribute and pre-processing directive?

匆匆过客 提交于 2019-12-12 04:08:37
问题 I am wondering what the difference is between #define MYSYMBOL #if MYSYMBOL public void foo () { // ... } #endif and #define MYSYMBOL [Conditional("MYSYMBOL")] public void foo () { // ... } ? Maybe it's obvious but if someone could give me a hint in the right direction I would be thankful :) 回答1: They are different. Using #if removes the enclosed code altogether, so any code that calls the method won't compile because the method has disappeared. You can also wrap any amount of code this way,

Linking to modules in external directory Compaq Visual Fortran command prompt

不羁的心 提交于 2019-12-11 21:31:02
问题 I know that this question is VERY specific, but I am using "Compaq Visual Fortran Optimizing Compiler, Version 6.5" (Fortran 90). To compile, e.g., I use: f90 constants.f90 main.f90 /compile_only And I'm not sure how to link aside from using the command "DF", but as far as I understand, that compiles AND links AND outputs a .exe to be executed. My problem is that I have a few modules that I USE in my main program, and I want those modules to be in one folder and my main program to be in

Implicit casting Integer calculation to float in C++

给你一囗甜甜゛ 提交于 2019-12-09 21:20:01
问题 Is there any compiler that has a directive or a parameter to cast integer calculation to float implicitly. For example: float f = (1/3)*5; cout << f; the "f" is "0", because calculation's constants(1, 3, 10) are integer. I want to convert integer calculation with a compiler directive or parameter. I mean, I won't use explicit casting or ".f" prefix like that: float f = ((float)1/3)*5; or float f = (1.0f/3.0f)*5.0f; Do you know any c/c++ compiler which has any parameter to do this process