error: `TFD_NONBLOCK' undeclared (first use in this function) - c

I am using timerfd mechanism, and getting this error on compilation: error:TFD_NONBLOCK' undeclared (first use in this function)`
How to resolve?
Here is the statement:
timer_fd = timerfd_create(CLOCK_REALTIME, TFD_NONBLOCK);
Looks like timerfd support is missing from libc. sys/timerfd.h is absent. Any workarounds for this?

To use timerfd_create(), you need to run Linux 2.6.25 (or higher) with glibc 2.8 (or higher).

Related

glib : glib 2.5 installation issue

I am working on Red Hat 6 with kernal version 2.6.32 , I am trying build glib 2.5 on my machine. And fail with following error:-
Log:-
../../gio/gfile.c: In function ‘splice_stream_with_progress’:
../../gio/gfile.c:3019: error: ‘F_SETPIPE_SZ’ undeclared (first use in this function)
../../gio/gfile.c:3019: error: (Each undeclared identifier is reported only once
../../gio/gfile.c:3019: error: for each function it appears in.)
../../gio/gfile.c:3023: error: ‘F_GETPIPE_SZ’ undeclared (first use in this function)
make[4]: *** [libgio_2_0_la-gfile.lo] Error 1
I can find the solution of at F_SETPIPE_SZ undeclared , placing #define _GNU_SOURCE before all includes in file gfile.c, But it didn't work. As mentioned in second answer: Older kernels (e.g. 2.6.32 as used in RHEL6) don't have them and we need bypass it in whatever you're building. How could we do that?
Appreciate your help .
Thanks in Advance.
The bug is fixed in this commit.
architectures without F_SETPIPE_SZ and F_GETPIPE_SZ such as or1k.
If those variables are undefined, put back previous behavior, buffer
size set to 1024 * 64
https://gitlab.gnome.org/GNOME/glib/-/commit/0beb62f564072f3585762c9c55fe894485993b62
You can apply the patch to your code.

error: ‘HZ’ undeclared (first use in this function)

I am trying to setup Dhrystone where I am getting the following error.
error: ‘HZ’ undeclared (first use in this function)
I don't the significance of HZ variable. I can compile the code straightaway by commenting the code which includes HZ variable. But is it the right way to do. Please help me in this regard.

Problems using graphviz as a library

I'm trying to use graphviz as a library for a C++ project, following the libguide provided here. However I'm having problems even compiling the examples in the appendix. When I try to compile demo.c using gcc I get the following output:
$ gcc -I/usr/local/Cellar/graphviz/2.28.0/include/ demo.c -L/usr/local/Cellar/graphviz/2.28.0/lib/ -lgvc -lgraph -lcdt
demo.c: In function ‘main’:
demo.c:14: error: ‘Agdirected’ undeclared (first use in this function)
demo.c:14: error: (Each undeclared identifier is reported only once
demo.c:14: error: for each function it appears in.)
demo.c:15: error: too many arguments to function ‘agnode’
demo.c:16: error: too many arguments to function ‘agnode’
demo.c:17: error: too many arguments to function ‘agedge’
Agdirected is found in cgraph.h, but if I change the includes in demo.c to
#include <graphviz/gvc.h>
#include <graphviz/cgraph.h>
Then all hell breaks loose (mostly conflicting declarations between the two headers). How can I include the necessary headers without the headache of all these conflicts?
Mac OS X 10.8.3, Graphviz 2.28.0, GCC 4.2.1
It seems after some experimentation that adding the flag
#define WITH_CGRAPH
has the effect of including cgraph.h, which gets rid of the "'Agdirected' undeclared" error.
The other errors can be fixed by changing the command line option in gcc from -lgraph to -lcgraph
The libguide you are using is the cgraph version, which assumes Graphviz 2.30 or later. With that version, the #define WITH_CGRAPH is already provided.

Unknown type name - 'DEV_BROADCAST_DEVICEINTERFACE' in MINGW

I took this code
as example to write a service. And I made some changes in my main function in such a way to work with command line parameters and removed
#define UNICODE
#define WINVER 0x502
Am using "MINGW".
Am getting the following errors:
usb_detect.c: In function 'ServiceMain':
usb_detect.c:123:16: error: unknown type name 'DEV_BROADCAST_DEVICEINTERFACE'
usb_detect.c:132:41: error: request for member 'dbcc_size' in something not a structure or union
usb_detect.c:132:61: error: 'DEV_BROADCAST_DEVICEINTERFACE' undeclared (first use in this function)
usb_detect.c:132:61: note: each undeclared identifier is reported only once for each function it appears in
usb_detect.c:133:41: error: request for member 'dbcc_devicetype' in something not a structure or union
usb_detect.c:133:60: error: 'DBT_DEVTYP_DEVICEINTERFACE' undeclared (first use in this function)
usb_detect.c:136:117: error: 'DEVICE_NOTIFY_SERVICE_HANDLE' undeclared (first use in this function)
usb_detect.c:136:148: error: 'DEVICE_NOTIFY_ALL_INTERFACE_CLASSES' undeclared (first use in this function)
If I uncomment the unicode and winver there are no errors, but command line parameters are not working..
I included dbt.h too..
The DEV_BROADCAST_DEVICEINTERFACE structure is only supported on Windows XP and later (as well as some of the other APIs that this code relies upon). It won't be defined in the Windows headers unless you're targeting that version of Windows or later.
To make sure that it's defined, you need to explicitly specify your target version of Windows at the top of your header file before you include Windows.h.
The typical pattern looks something like this:
#include <WinSDKVer.h>
#define _WIN32_WINNT _WIN32_WINNT_WINXP
#include <SDKDDKVer.h>
The original version of the code you tried had this line, which you removed:
#define WINVER 0x502
That explicitly set the target Windows version to Windows Server 2003 (Windows NT v5.2). Removing it means that you revert to the lowest common denominator, which is a version of Windows prior to XP, where the DEV_BROADCAST_DEVICEINTERFACE structure is not defined.
It's also not clear why you're removing the UNICODE define. It's 2012—any app you're building should be targeting Unicode. Leave that defined as well.

How to disable "'variable' undeclared (first use in this function)" warning in RHIDE (DJGPP)

I have an old C program (which I didn't write) which worked for me before on a machine I had using DJGPP with RHIDE under DOS.
The problem is, that since I've moved to a new machine, when I try and compile it, I get loads (100s) of "'variable' undeclared (first use in this function)" warnings.
I don't have the time to go back over this and amend the code at the minute... is there a way to disable this warning and let me build?
Thanks for any help.
EDIT:
Sorry guys, this isn't my area at all. The following code:
char *sbname;
sbname = calloc (99, sizeof(char));
The second line produces an error of:
Error: 'sbname' undeclared (first use in this function)
This hadn't produced any errors on the last machine, so I assumed there is a setup issue.
Thanks

Resources