Skip to content
Advertisement

Tag: c++

why my x64 process base address not start from 0x400000?

I learned from this link Why is address 0x400000 chosen as a start of text segment in x86_64 ABI? that 64-bit Linux process start address by default should be 0x400000, but on my Ubuntu, I only found my bash process starts from a very high base address (0x55971cea6000). Any one knows why? and how does dynamic linker choose the start

How to format unix time (sec+usec+nsec) string?

I have this function which works just fine. It gives me current system time the way I need: Now I need to also be able to print timestamps I receive from 3rd party lib in 2-3 variables – sec, usec, nsec (optional). Can I somehow construct timespec from these values and reuse the code I already have? Answer You don’t

Should mqueues be protected by semaphores

Should read mq_receive and write mq_send be protected by semaphores when accessing a queue in a multiprocess program or is there any sort of protection alredy built in Answer It’s always recomended to read the formal documentation for API you are using. Specifcally for mq_receive and mq_send these are: https://man7.org/linux/man-pages/man3/mq_send.3.html https://man7.org/linux/man-pages/man3/mq_receive.3.html In the atributes section you can see that both

Execute cat command to overwrite file

I am trying to execute the cat command from my C# code, but I am running into problems. So, this is just a very simple test, but I end up with the error: Error: cat: ‘>’: No such file or directory Now… both source and target files actually exist.. and same result if target file does not exist. If I

Can’t redirect printf to pipe

I want to redirect the output of printf to a pipe, but for some reason it doesn’t seem to work. What does work is using write instead. This is my program if I replace write with the commented line, my program just blocks Answer Either add a new line character (n) to your output or use fflush() as Barmar suggests:

why does the local array has extra empty location at the end(c/c++/gcc)?

Check below program, In the above program, even though array size is 10, after the first array there is exactly 6 extra locations reserved in the stack (12bytes), I am wondering why this extra space got reserved? and this extra space size is varying for different size(Its not 12 for size 20). Can anybody explain the concept behind these allocations?

Fast byte copy C++11

I need to convert C# app which uses extensively bytes manipulation. An example: Basically BitConverter and Buffer.BlockCopy called 100s times per sec. There are several classes that inherit from the base class above doing more specific tasks. For example: What approach in C++ should I look into? Answer Best option, in my opinion, is to actually go to C –

Advertisement