In Linux, when memory is requested (using calloc / malloc), if a contiguous block of the requested size is not available does the kernel map multiple separate pieces of memory into one single virtual block and hand it over to the application or is it allocated on disk? If it is allocated on disk, when a large enough block becomes
Tag: c++
How do you convert c code into assembly’s hex representation?
Edit: It appears I have a lot more reading to do… Also, for those telling me this is a bad idea, it’s for a buffer overflow exercise. I have a fairly simple C program: I want to turn it into hex assembly code. Think something like: I tried doing: And that gave me a nice long string of hex. But
Disable variable-length automatic arrays in gcc
I couldn’t disable it even though by using -std=c89 flag. How can I disable it? Answer You can generate an error for variable length arrays using a compiler flag:
CUDA C++: Using a template function which calls a template kernel
I have a class which has a template function. This function calls a template kernel. I’m doing my development in Nsight on a Linux box. In doing this, I encounter the following pair of conflicting requirements: 1 – When implementing a template function, the definition must appear in the *.h (or *.cu.h) file since the code is not generated until
boost logging channel filtering in shared libraries not working as expected on linux
I have an executable for both Linux and Windows with three dlls/shared libraries, and I’m using boost.log for logging. I wish to have a separate, file log for each module. My approach was to create a severity_channel_logger_mt for each module, constructed in a singleton for each module with the channel name. Each module then creates its own file sink on
linux – How do I capture all of my compiler’s output to a file as well as need to display output
The below program redirects all my output to log file. I need to display all the output along with log file. How can this be achieved? Answer You could use tee:
grantpt report error after unshare
I have a small program, which tries to create a pseudoterminal after unshare. the output is: The Code: If I remove flag |= CLONE_NEWUSER;, there is not error reported. Can you help to explain why this happens? thanks in advance! Answer Since I’ve had the same issue I have also looked into this. Here are my findings: grantpt(3) tries to
Proper error handling for fclose impossible (according to manpage)?
So I’m studying fclose manpage for quite I while and my conclusion is that if fclose is interrupted by some signal, according to the manpage there is no way to recover…? Am I missing some point? Usually, with unbuffered POSIX functions (open, close, write, etc…) there is ALWAYS a way to recover from signal interruption (EINTR) by restarting the call;
C compiler cannot create executables on OpenSUSE
I’ve tried to compile xdebug from sources, but I become this output: There is my config.log. I’ve found possible error: /usr/lib64/gcc/x86_64-suse-linux/4.8/../../../../x86_64-suse-linux/bin/ld: i386 architecture of input file ‘/usr/lib/crt1.o’ is incompatible with i386:x86-64 output /usr/lib64/gcc/x86_64-suse-linux/4.8/../../../../x86_64-suse-linux/bin/ld: i386 architecture of input file ‘/usr/lib/crti.o’ is incompatible with i386:x86-64 output /usr/lib64/gcc/x86_64-suse-linux/4.8/../../../../x86_64-suse-linux/bin/ld: i386 architecture of input file ‘/usr/lib/crtn.o’ is incompatible with i386:x86-64 output /usr/lib64/gcc/x86_64-suse-linux/4.8/../../../../x86_64-suse-linux/bin/ld: dynamic STT_GNU_IFUNC symbol
How to programmatically prevent linux computer from sleeping or turning on screensaver?
While developing a small cross-platform game on C++, I got stuck with following issue: when players are playing with a USB gamepad without touching a keyboard or mouse, the computer sleeps automatically while they’re playing. In Windows, it can be done easily using SetThreadExecutionState function. In OS X, I think it can be done with UpdateSystemActivity but not tested yet.