glib : glib 2.5 installation issue - c

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.

Related

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.

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.

Mac network ping source code compile error

I download the Mac OS network ping source code from Apple: http://www.opensource.apple.com/tarballs/network_cmds/network_cmds-356.8.tar.gz
and compile it in xcode, but get errors in both 10.7 and 10.6,
'IP_NO_IFT_CELLULAR' undeclared (first use in this function)
'SO_TRAFFIC_CLASS' undeclared (first use in this function)
'SO_RECV_TRAFFIC_CLASS' undeclared (first use in this function)
'SO_TRAFFIC_CLASS' undeclared (first use in this function)
Did I miss something?
I thought it was possible that you needed to import a networking framework into your project, but Apple doesn't provide any description or information about the project you've downloaded.
For posterity's sake:
To add frameworks, select the project in the top left, then click your target, pick 'Build Phases' from the top of the resulting page, 'Link Binary With Libraries', '+'.
I finally managed to get it to build after exhaustive googling by adding the following to the ping.c file (the one flagged with the errors):
#define IP_NO_IFT_CELLULAR 6969 /* for internal use only */
#define IP_NO_IFT_PDP IP_NO_IFT_CELLULAR /* deprecated */
#define SO_TRAFFIC_CLASS 0x1086 /* Traffic class (int)*/
#define SO_RECV_TRAFFIC_CLASS 0x1087 /* Receive traffic class (bool)*/
Which amusingly came from other open source Apple projects that Google had indexed.

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

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).

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