How to construct Nan in windows environment? - visual-studio

I want to return Nan when item is not number.
double getValue(c_struct item)
{
if (!c_struct_isnumber(item)) {
return 0.0/0.0; // in linux is ok, but failed in windows
}
return item->value;
}
in linux is ok; but when I compile it in visual studio, then get an error:error C2124: divide or mod by zero.
anyone could help me?

Related

What is the meaning of this code line?? and What is the solution for the error?? I have this issue in Sniper Simulator version 7.2

What is the meaning of this code line?? and What is the solution for the error?? I have this issue in Sniper Simulator version 7.2 with Pin 3.5 on Linux Debian 4.19.67-2+deb10u1 (2019-09-20) x86_64 GNU/Linux. My gcc version is 8.3.0
Besides This is not my codes...
The code is:
IALARM* ALARM_MANAGER::GenAddress(){
string hex = "0x";
BOOL ctxt = _control_chain->NeedContext();
if (_alarm_value.compare(0, 2, hex) == 0){
//this is a raw address
return new ALARM_ADDRESS(_alarm_value,_tid,_count,ctxt,this);
}
if (_alarm_value.find("+",0) == string::npos){
//this is a symbol
return new ALARM_SYMBOL(_alarm_value,_tid,_count,ctxt,this);
}
else{
vector<string> tokens;
PARSER::SplitArgs("+",_alarm_value,tokens);
return new ALARM_IMAGE(tokens[0],tokens[1],_tid,_count,ctxt,this);
}
The error is:
alarm_manager.cpp:137:67: error: ‘new’ of type ‘CONTROLLER::ALARM_SYMBOL’ with extended alignment 64 [-Werror=aligned-new=]
return new ALARM_SYMBOL(_alarm_value,_tid,_count,ctxt,this);
^
alarm_manager.cpp:157:64: note: uses ‘void* operator new(size_t)’, which does not have an alignment parameter
alarm_manager.cpp:157:64: note: use ‘-faligned-new’ to enable C++17 over-aligned new support
As Kamil said it gets solved by adding -faligned-new to the relative makefile.
use ‘-faligned-new’ to enable C++17 over-aligned new support

Unable to Call Function in Go debugger

I am following the "Little Go Book" by Karl Seguin, in order to learn Go.
My working environment is Visual Studio Code.
Upon debugging, when I try to call a function from the debug console, i get the following error:
"function calls not allowed without using 'call'", if I try using "call fib(10)", i get "Unable to eval expression: "1:6: expected 'EOF', found fib".
This is the function I am trying to evaluate:
//Fibonnaci
func fib(n int) int64 {
if n == 0 {
return 0
} else if n == 1 {
return 1
} else {
return fib(n-1) + fib(n-2)
}
}
If i try to call the function from the code itself ( from the main() for instance, it works perfectly).
However, if I set a breakpoint and try to call the same function from the debugger console, I get the below error:
Eval error: function calls not allowed without using 'call'
call fib(10)
Unable to eval expression: "1:6: expected 'EOF', found fib"
Failed to eval expression: {
"Expr": "call fib(10)",
"Scope": {
"goroutineID": 1,
"frame": 0
},
"Cfg": {
"followPointers": true,
"maxVariableRecurse": 1,
"maxStringLen": 64,
"maxArrayValues": 64,
"maxStructFields": -1
}
}
Looks like "Function calls via delve 'call' are not supported" yet github issue in microsoft/vscode-go repo :(
The issue vscode-go issue 100 "debug: support function calls via delve 'call'" just got closed with PR 101 and commit 5a7752c / CL 249377
Delve supports function calls. Even though it is still experimental and can be applied only to a limited set of functions, this is a useful feature, many vscode-go users long for.
Unlike other javascript/typescript debuggers, delve treats function calls specially and requires different call paths than usual expression evaluation.
That is because Go is a compiled, runtime-managed GC language, calling a function safely from debugger is complex.
DAP and VS Code UI does not distinguish function calls and other expression evaluation either, so we have to implement this in the same evaluateRequest context.
We use a heuristic to guess which route (call or expression evaluation) we need to take based on evaluateRequest's request.
This is part of the 0.17.0 milestone, yet to be released, and available for now in the nightly build.

Recursion and Xcode 7 compile error

this is a simple recursion function
func recursion(parameter : Double)
{
if parameter < 12
{
recursion(parameter + 1)
}
print(parameter)
}
when i am trying to put a simple value for example 0 or 1
recursion(0)
i get a compile error saying Missing argument for #1 in call any idea why this is happening?
btw if i change the function to
func recursion(parameter : Double)
{
if parameter > 1
{
recursion(parameter - 1)
}
print(parameter)
}
everything works fine
any ideas? i am using Xcode 7 beta
Your code works fine, just make a Clean & Build and then try it again and the initial compile error should disappear. Remember that Xcode 7 is still in Beta, Apple is working to fix this kind of false compile errors properly.
I hope this help you.

TypeScript compiler error: Expected ';' or ']'

This is a node project in VS 2013 with TypeScript tools and Web Essential installed (but no Resharper). I'm in process converting my javascript to typescript, and it seems to go well. However, I got a lot of errors in the Error List like
Error 1 Expected ';' C:\Azure\public\js\prototypes.ts 6 11
Error 2 Expected ',' or ']' C:\Azure\public\js\prototypes.ts 7 13
Error 3 Expected ';' C:\Azure\public\js\prototypes.ts 7 22
Error 4 Expected ',' C:\Azure\public\js\prototypes.ts 13 30
Error 5 Expected '{' C:\Azure\public\js\prototypes.ts 13 40
Error 6 Expected ';' C:\Azure\public\js\prototypes.ts 13 49
Here is the first few lines of prototypes.js:
/// <reference path="../../typings/moment/moment.d.ts" />
'use strict';
//-------------------------------------------------
// Math
//-------------------------------------------------
interface Math {
lg(value: number): number;
roundUp(value: number, digits: number): number;
roundDown(value: number, digits: number): number;
}
if (!Math.lg) {
Math.lg = function (value: number) : number {
return Math.log(value) / Math.LN10;
};
}
if (!Math.roundUp) {
Math.roundUp = function (value, digits) {
var factor = Math.pow(10, Math.floor(Math.lg(Math.abs(value))) - digits || 0);
return Math.ceil(value / factor) * factor;
};
}
if (!Math.roundDown) {
Math.roundDown = function (value, digits) {
var factor = Math.pow(10, Math.floor(Math.lg(Math.abs(value))) - digits || 1);
return Math.floor(value / factor) * factor;
};
}
Strange thing is that, even with those errors in the Error list, build succeeded and the app seems to be running fine. I also tried to uninstall WebEssential and TypeScript tools and then reinstall them, but no difference.
What is it complaining about?
UPDATE:
When I saw 1.5Beta, I immediately installed it. To my disappointment, I got more errors. Then, I decided to rollback to 1.4. But even worse...now when I open the same project it complains
Your project file uses a different version of the TypeScript
compiler and tools than is currently installed on this machine. No
compiler was found at C:\Program Files (x86)\Microsoft
SDKs\TypeScript\1.4\1.4\tsc.exe. You may be able to fix this problem
by changing the <TypeScriptToolsVersion> element in your project
file.
I don't know why the path has an extra \1.4 now. Also, I can't find <TypeScriptToolsVersion> element in my project file. I searched everywhere (including registry), and couldn't find anywhere having a path like \1.4\1.4. It's becoming my TypeScript nightmare now.
even with those errors in the Error list, build succeeded and the app seems to be running fine.
TypeScript will not block a .js emit/build in the presence of type errors. This is to make it easier for you to migrate js code to ts.
That said, the code you posted also works fine:

Scala IDE Debugger "step into" behavior

Current behavior:
Put a breakpoint on the case Twice(n) ... line.
On "step into" the control goes to x match { line
On "step into" the control goes to def TwiceTest = { line
On further "step into" the control goes to if (z % 2 == 0)... line.
Expected behavior:
Put a breakpoint on the case Twice(n) ... line.
On "step into" the control goes to if (z % 2 == 0)... line.
Code Snippet
object testobj extends App {
def TwiceTest = {
val x = Twice(21)
x match {
case Twice(n) => Console.println(n)
} // prints 21
}
TwiceTest
}
object Twice {
def apply(x: Int): Int = x * 2
def unapply(z: Int): Option[Int] = {
if (z % 2 == 0) Some(z / 2) else None
}
}
The current behavior is irritating while debugging a scala program with lots of nested extractors. I tried this with the new Scala debugger as well as the Java debugger but with the same result.
Step Filtering also does not help in this case.
As a workaround, I am putting a breakpoint in the unapply method and running resume from the first breakpoint. Can someone please suggest me a cleaner method.
Edit 1
I am using Scala-IDE (latest nightly build. 2.1.0.nightly-2_09-201208250315-529cd70 )
Eclipse Version: Indigo Service Release 2 Build id: 20120216-1857
OS: Windows 7 ( 64 bit)
The line number information in the bytecode is wrong. It is not an issue with the IDE, but the Scala compiler. When pattern matching is compiled, synthetic code sometimes gets the wrong position information.
I assume you are using Scala 2.9.2. In the next version of Scala (2.10.0), there are significant improvements in the pattern matcher, so it would be good to give it a try.

Resources