If I'm trying to indiscriminately silence compiler messages the compiler command line parameter -vmXXXX works perfectly for the whole project. However, if I'm trying to silence messages selectively in the source I have to use the {$WARN XXXX OFF} compiler directive.
The problem is... I am having a really hard time understanding the rules of how that compiler directive is applied. In the example below of 1 program and 2 units, if you uncomment the {$WARN XXXX OFF} command one at a time, what will happen is not what I would expect (the result is written in the comment for each compiler directive).
Is there anyone who can explain exactly how that compiler directive works?
Program:
program Project1;
//{$WARN 4055 OFF} // will silence the unit2 hint but not the unit1 hint
uses
Unit1;
//{$WARN 4055 OFF} // will silence neither the unit2 hint nor the unit1 hint
begin
if convert_it(0)=nil then
halt(1);
end.
First Unit:
unit Unit1;
//{$WARN 4055 OFF} // will silence the unit2 hint but not the unit1 hint
interface
//{$WARN 4055 OFF} // will silence the unit2 hint but not the unit1 hint
function convert_it(avalue:longint):pointer;
//{$WARN 4055 OFF} // will silence the unit2 hint but not the unit1 hint
implementation
//{$WARN 4055 OFF} // will silence the unit2 hint but not the unit1 hint
uses
unit2;
//{$WARN 4055 OFF} // will silence the unit1 hint but not the unit2 hint
function convert_it(avalue:longint):pointer;
begin
result:=pointer(do_it(avalue));
end;
end.
Second Unit:
unit Unit2;
//{$WARN 4055 OFF} // will silence the unit2 hint but not the unit1 hint
interface
//{$WARN 4055 OFF} // will silence the unit2 hint but not the unit1 hint
function do_it(avalue:longint):longint;
//{$WARN 4055 OFF} // will silence the unit2 hint but not the unit1 hint
implementation
//{$WARN 4055 OFF} // will silence the unit2 hint but not the unit1 hint
function do_it(avalue:longint):longint;
var
p:pointer;
begin
p:=pointer(avalue);
if p=nil then
result:=avalue+1
else
result:=avalue-1;
end;
end.
From the manual:
Local directives can occur more than once in a unit or program, If
they have a command line counterpart, the command line argument is
restored as the default for each compiled file. The local directives
influence the compiler’s behaviour from the moment they’re encountered
until the moment another switch annihilates their behaviour, or the
end of the current unit or program is reached.
So the directives you use are valid from their declaration to the end of a unit, following the use clauses, after what the default value is restored.
For each unit, for each nth directive
Program
1: the directive is activated, still valid in unit1 because of the use, still valid in unit2 because of the use. But after unit2 (end of a unit) the default value is restored, so you got the message in unit1.
2: the directive is activated after the use so it has no effect whatever is the unit.
Unit1
1: the directive is activated, still valid in unit2 because of the use. But after unit2 (end of a unit) the default value is restored, so you got the message in unit1.
2: ditto
3: ditto
4: ditto
5: the directive is only activated for unit1 implementation section.
Unit2, all cases: the directive is only activated for unit2.
The tricky thing to get here is that it follows the use.
Related
In a multi-gpu system, I use the return value of
cudaError_t cudaDeviceDisablePeerAccess ( int peerDevice ) to determine if peer access is disabled. In that case, the function returns cudaErrorPeerAccessNotEnabled
This is not an error in my program, but produces a warning in both cuda-gdb and cuda-memcheck since an API call did not return cudaSuccess.
In the same manner cudaDeviceEnablePeerAccess returns cudaErrorPeerAccessAlreadyEnabled if access has already been enabled.
How can one find out if peer access is enabled / disabled without producing a warning?
Summarizing comments into an answer: you can't.
The runtime API isn't blessed with the ability to have informational/warning level status returns and error returns. Everything which isn't success is treated as an error. And the toolchain utilities like cuda-memcheck cannot be instructed to ignore errors. The default beahaviour is to report and continue, so it will not interfere with anything, but it will emit an error message.
If you want to avoid the errors then you will need to build some layers of your own state tracking and condition preemption to avoid potential errors being returned.
I am programming my arduino uno on the new raspberry pi 4. I have installed arduino IDE v1.8.9 and I am having issues in compiling the code.
I am getting an error.
avr-g++: error: device-specs/specs-atmega328p: No such file or directory
Please Help.
I am running Rasbian Os
/*
AnalogReadSerial
Reads an analog input on pin 0, prints the result to the Serial Monitor.
Graphical representation is available using Serial Plotter (Tools > Serial Plotter menu).
Attach the center pin of a potentiometer to pin A0, and the outside pins to +5V and ground.
This example code is in the public domain.
http://www.arduino.cc/en/Tutorial/AnalogReadSerial
*/
// the setup routine runs once when you press reset:
void setup() {
// initialize serial communication at 9600 bits per second:
Serial.begin(9600);
}
// the loop routine runs over and over again forever:
void loop() {
// read the input on analog pin 0:
int sensorValue = analogRead(A0);
// print out the value you read:
Serial.println(sensorValue);
delay(1); // delay in between reads for stability
}
This is the -tools option for arduino-builder missing the location avr.
A setting like
-tools /home/owner/arduino-1.8.10/hardware/tools/avr
is needed so as to find the spec files. Set your compile output to verbose to see the compile command that is issued, and verify above line is present.
More info: https://github.com/arduino/arduino-builder/issues/263
In order to deploy a smart contract to the network we need three the following information:
From the web3js spec:
// deploy new contract
var contractInstance = MyContract.new([constructorParam1] [, constructorParam2], {data: '0x12345...', from: myAccount, gas: 1000000});
Correct me if I am wrong:
constructorParams - all the data that is passed to the smart contract constructor,
from - determines the address this contract is deployed from
gas - gas limit on how much this transaction can consume
What is data, is it sort of a compiled solidity code of the contract, if so why then do we need it if we have already specified ABI of this contract?
How do I get this data parameter? I also get an error in my console when I try to deploy the contract to the network without specifying data parameter:
Error: "invalid argument 0: json: cannot unmarshal hex string without 0x prefix into Go struct field SendTxArgs.data of type hexutil.Bytes"
Yes, data is the compiled byte code for your smart contract.
The ABI doesn't have the code for running the contract; it just describes the interface (what functions exist with what parameters).
You get the bytecode from the compiler. Without knowing what tool you're using, it's hard to be more specific.
const data = contract.methods.contractFunction(contractArgument).encodeABI()
This will encode a function of the contract into byte code, which can then be passed into the data parameter.
contractFunction(contractArgument)
will be different for you and the function you are wanting to call.
I am getting the following error when running the default generated kernel when creating a CUDA project in VS Community:
addKernel launch failed: invalid device function
addWithCuda failed!
I searched for how to solve it, and found out that have to change the Project->Properties->CUDA C/C++->Device->Code Generation(default values for [architecture, code] are compute_20,sm_20), but I couldn't find the values needed for my graphic card (GeForce 8400 GS)
Is there any list on the net for the [architecture, code] or is it possible to get them by any command?
The numeric value in compute_XX and sm_XX are the Compute Capability (CC) for your CUDA device.
You can lookup this link http://en.wikipedia.org/wiki/CUDA#Supported_GPUs for a (maybe not complete) list of GPUs and there corresponding CC.
Your quite old 8400 GS (when I remember correctly) hosts a G86 chip which supports CC 1.1.
So you have to change to compute_11,sm_11
`
Merged with Why do I get no warning when protocol methods are not specified?.
I'm using Xcode 4, have a simple class interface defined and I added NSTableViewDelegate and NSTableViewDataSource protocols to the interface definition. I.e,
#interface foo : NSObject < NSTableViewDelegate, NSTableViewDataSource>
In my build settings, I have confirmed that the option "Incomplete Objective-C Protocols" warning is enabled (for Debug/Any Architecture etc) and I should get a compile time warning for the non-optional methods required for the NSTableViewDataSource protocol. However, I get no warnings at all but then at runtime I see the message in the log that the methods aren't defined.
Anyone know why?