I have some C code (on Linux) that needs to run in a thread safe manner. It’s very low contention but I have to guard it to ensure correctness. I have the option of using local variables to guard it (which will work based on how the code is written) but since I have a mutex variable, which is the
Tag: c++
What is the cause of the difference in return value between Linux and Windows and how to fix it?
Here is the code that I tried to return an object of a class. but I got different results from CentOs (gcc) and visual studio 2013. In the cls.cpp, with gcc, it works well, I get the results such as detector.name = “t_name”, detector.stride = 5. but the values in the detector are “” and 0 under vs2013. It seems
Cross-platform file name handling in .NET Core
How to handle file name in System.IO classes in a cross-platform manner to make it work on Windows and Linux? For example, I write this code that works perfectly on Windows, however it doesn’t create a file on Ubuntu Linux: Answer Windows using Backslash. Linux using Slash. Path.Combine set the right symbol : Path.Combine Method – MSDN
Uniscan: loadable library and perl binaries are mismatched
Uniscan is a tool for scanning websites which comes in kali linux and other pen tests distros. I used to use it weekly to test my applications but after some updates of my linux tools it is now giving the following error when I run it: xs/Moose.c: loadable library and perl binaries are mismatched (got handshake key 0xdb00080, needed 0xdb80080)
How to emit signal when the label text change?
I have 3 forms (main form, password form and menu form). The user clicks menu to open menu form, but before the menu form shows, the password form display to authenticate the user. He could display RFID card or enter his Id and password. When he puts his card the socket notifier in main form recieved the RFID card data
How to print a binary value(1010) into decimal value(10) in GDB?
I want to print the decimal value of 1010 in gdb, but it prints the result as it is what I gave last. Answer GDB’s p[rint] command prints the value of the expression you provide, which is interpreted in the source language of the program being debugged. In C, your 1010 is a decimal literal, not a binary literal, so
Socket connection in Linux
I just got a error from connect API in linux. I knew ‘connect’ will return zero if connection is successful, I got return value “3” is it error code? or is there something else what don’t know? I got value 3 from sock. Answer To get the return value of connect(), it is most straight forward to use a variable
Why is SIGFPE not triggered after adding a printf line?
I am playing with a simple program (source code below). And my computer configuration: Linux mymachine 3.13.0-49-generic #83-Ubuntu SMP Fri Apr 10 20:11:33 UTC 2015 x86_64 x86_64 x86_64 GNU/Linux gcc version 4.8.4 (Ubuntu 4.8.4-2ubuntu1~14.04.3) I intend to trigger the SIGFPE in this program by calling the executable in this way: As you can see, the SIGFPE is successfully triggered. However,
Is it possible to set timer with local time in Linux?
I’m on my IOT project with raspberry pi, And I want to raise event in certain time like 06:00:00 and 12:00:00 But I can’t do this with jiffies because jiffies only counts the time since the os started. I have an Idea : I may raise interrupt every second and check local time, compare it with certain time. But I
Why does octal dump output the ascii code for an integer variable instead of the binary code?
This is the code in C to input a character and integer variable to a file. So lets say the file name is text and the od command is invoked.. This is the output of the command Why does it print the ASCII values for both of the value 40 and not the hex code 0028 for the integer variable?