Hi below is my coding snippet When statement1 & statement2 are commented I am expecting child thread to change my testrunning variable first before main thread but it is working properly only when statement1 and statement2 are uncommented. My question is why in child thread mutex lock is not locking my testrunning variable . it is allowing main thread to
Tag: c++
Windows C Runtime toupper slow when locale set
I’m diagnosing an edge case in a cross platform (Windows and Linux) application where toupper is substantially slower on Windows. I’m assuming this is the same for tolower as well. Originally I tested this with a simple C program on each without locale information set or even including the header file and there was very little performance difference. Test was
Double Free – crash or no crash
Can someone explain me why freeing a twice in a row causes a crash, but freeing a first, then b, and then a again does not crash? I know that a free will insert the heap chunk in a double linked free list. Freeing twice would insert the same chunk twice in the free list. But why is the crash
Behavior of fgetc() function in C
I am looking for an easy way to manage file opening and closing in x86-64 assembly on linux. I thought the easiest way would be to write a c file containing functions that I could call without having to worry about stability. So I wrote this function : And then I read the port like so: Where PORT.p is a
How to compare a string with EOF?
I’ve created a program that acts like a unix-shell. Namely if type something like “./helloWorld” it will execute the program and then wait for additional input. If the input is EOF (Ctrl + D) then the program must terminate. What I’m struggling with is trying to compare the input without using getchar() or any method that requires additional input. Here’s
Could not load type ‘System.Net.Security.SslStream’
I’ve this simple C# program: and I compile it with mono (mcs): when I execute, an error thrown: My Npgsql.dll version My compiler: Finally, my environment: Thank you Answer I have one question – do you have library Mono.Security.dll inside bin folder? If so, please delete it and try again.
OpenCV 3.1.0 won’t compile with CMake
I know there are many supposed duplicates for this matter, but since none of the answers worked for me I’d rather ask another question. My project won’t compile with CMake: Found package configuration file: /usr/share/OpenCV/OpenCVConfig.cmake but it set OpenCV_FOUND to FALSE so package “OpenCV” is considered to be NOT FOUND. My CMakeLists.txt is as follows: The error happens on the
How do I read the whole command line?
Command $ ls -l | ./main.out The output will show My question is, how do I make my program to read the command before that, ls -l Answer Command line parameters are passed as arguments when calling the program. And your program will read the entire command line arguments. But What you are doing ($ ls -l | ./main.out) is
Using the setuid bit in Linux
I have this C file: I compile it, set the UID and GID both to root and set the setuid bit, so that it looks like this: However when I call $ ./a.out I still get: What am I doing wrong? Answer The real user ID is still the user that called the program, but the effective user ID is
QThreads using MinGw doesn’t work properly under windows
I’m developing a large optimzation tool using Qt. For a better CPU usage I use QThreads. Then I move worker objects (derived from QObject, containing non QObject data members) into the threads. Everything looks fine, builds fine and runs smoothly on Linux using GCC and Qt 4.8 However using MinGw using Qt 5.5 under Windows, the calculation took much longer.