Skip to content
Advertisement

Tag: c++

‘DT_REG Undeclared’ even when using header file in function

I’m using the <dirent.h> header file in the function I’m referencing DT_REG, however, I’m getting error an saying ” ‘DT_REG’ undeclared (first use in this function) ” The snippet of the code is: In my makefile I’m using “cc -std=c11 -Wall -Werror -pedantic”. Any ideas for the reason? Answer DT_REG is not part of ISO C11 extensions. Setting -std=c11 strictly

Ping program implementation in C about recvfrom() doubts

I am searching for a long time on net. But no use. Please help or try to give some ideas how to achieve this. I have finished writing the program, and today when I tested the ping loopback address, after sending the packet, the function recvfrom() received the “first” packet (type 8), and the second recvfrom() received the response packet

Why does this nostdlib C++ code segfault when I call a function with a thread local variable? But not with a global var or when I access members?

Assembly included. This weekend I tried to get my own small library running without any C libs and the thread local stuff is giving me problems. Below you can see I created a struct called Try1 (because it’s my first attempt!) If I set the thread local variable and use it, the code seems to execute fine. If I call

Compiler cannot find header file within header file in C++

I have a header file provided by yaml-cpp library, yaml.h yaml.h: main.cpp All the header files are in the same directory (/home/user/application/libs/yaml-cpp/include), but the compiler is unable to find parser.h and all the other includes. Why is this so and how do I fix it? I have tried using g++ -I/home/user/application/libs/yaml-cpp/include main.cpp but that did not work. I am on

SWIG: Access Array of Structs in Python

Say I have the following static constexpr array of c struct: How can I access elements in ns1::ns2::PERSONS in python by using swig? One way I can think of is to create a accessor like const Person& get(uint32_t index) in the swig interface file. Tho, I wonder whether there is a more elegant way that I don’t have to create

Kill child process spawned with execl without making it zombie

I need to spawn a long-running child process and then kill it from the parent code. At the moment I do like this: This does the job in the sense that the child process is stopped, but then it remains as a zombie. I tried to completely remove it by adding: to no avail. I must be doing something wrong

How does the bitwise AND help in the if statements in the Linux Kernel?

Background on what the code is trying to achieve: “Various parameters of the new process (e.g., euid, egid, argument list, environment, filename, etc.) that are subsequently passed to other functions are, for the sake of simplicity, combined into a structure of type linux_binprm. prepare_binprm is used to supply a number of parent process values (above all, the effective UID and

Advertisement