Header file with FNM_EXTMATCH - c

Everything goes well with this statement:
fnmatch(pattern, href, FNM_EXTMATCH);
when I oder the header files as below:
#include <fnmatch.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include "link.h"
But the gcc says that FNM_EXTMATCH not defined when I order the head files instead as below:
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <fnmatch.h>
#include "link.h"
So where is the conflict?

FNM_EXTMATCH is a GNU extension. If you wish to use it, put
#define _GNU_SOURCE
at the top of your file (before any #include statements). Note, however, that it will not be portable to non-GNU systems -- those without gcc and glibc.

Related

undefined reference to xxxxxxx, linking issue stm32cube

I am unable to compile my code successfully due to undefined references.
I am using the STM32Cube IDE compiler which is based of atollic true studio.
The undefined references are due to headers not linking.
I have included the headers into my main program and have included them in the include path for the compiler.
#include "base64_codec_transport.h"
#include "line_buffer_transport.h"
#include "modem_ussd_transport.h"
#include "thingstream_transport.h"
#include "client_api.h"
#include "client_platform.h"
#include "client_set_callback.h"
#include "custom_modem_transport.h"
#include "debug_printf_core.h"
#include "log_client_transport.h"
#include "log_modem_transport.h"
#include "log_protocol_transport.h"
#include "log_transport.h"
#include "modem2_transport.h"
#include "modem_set_callback.h"
#include "modem_transport.h"
#include "predefined_topics.h"
#include "quectel_modem2_config.h"
#include "ring_buffer_transport.h"
#include "sdk_data.h"
#include "serial_transport.h"
#include "sim7600_modem2_config.h"
#include "transport_api.h"
#include "ublox_modem2_config.h"
The consol errors are below:
All these functions are defined in their respective headers as follows, to give one example.
#define line_buffer_transport_create Thingstream_createLineBufferTransport
which then points to
extern ThingstreamTransportResult Thingstream_line_buffer_deliver(ThingstreamTransport *self);
I have also rebuilt the index multiple times and still no success.
I don't know what else to do to solve this.

C macro name must be an identifier

I've created a c project and this is the beginning of the main.c file:
#include <curl/curl.h>
#include <stdbool.h>
#include <stdint.h>
#include <stdlib.h>
#include <string.h>
#include "include/httpdef.h"
//...some code
The httpdef.h beginning is this:
#ifndef httpdef
#define httpdef
#include <stdint.h>
#include <stdbool.h>
#include <string.h>
#include <stdlib.h>
#include <curl/curl.h>
//definitions
#endif
At the very first line of both files I get the error from the gcc compiler:
macro name must be an identifier
What could be the problem?
EDIT: I realized now that actually the compiler doesn't give any error, it's my vim plugin (YouCOmpleteMe) that generates this error. If I compile everything works and the error doesn't appear

handling warning: implicit declaration of function ‘sigignore’

Here's my code:
#include <sys/types.h>
#include <stdio.h>
#include <dirent.h>
#include <sys/stat.h>
#include <fcntl.h>
#include <unistd.h>
#include <time.h>
#include <sys/time.h>
#include <assert.h>
#include <errno.h>
#include <string.h>
#include <stdlib.h>
#include <signal.h>
int main(int argc, char** argv) {
sigignore(SIGTERM);
return 0;
}
Why do I get the following warning and how could I remove it?
implicit declaration of function ‘sigignore’
[-Wimplicit-function-declaration] sigignore(SIGTERM);
The program must be compiled like this: gcc -o foo.o foo.c.
Thanks
Man sigignore tells you to use #define _XOPEN_SOURCE 500 to enable sigignore. More on X/Open can be found here
The function you want to call has been marked as obsolete 15 years ago. The normal way to discourage people from using those functions (without actually breaking programs) is to have the implementation of the function left in the standard library, but remove the declaration from header files (or at least make it hard to enable).
Use sigaction or sigprocmask (depending on what you actually want to accomplish).

Unable to Open an Include file "Protocols.h" using C Compiler

I have a c Program and it was running Perfectly, but now i want to run it in Windows. So i am trying to compile the code in the Windows 7 Operating System, using Turboc3.
When i am compiling, i am getting an error "Unable to open include file Protocols.h"
But the Protocols.h file exists in the Directory. And all the directories are set perfectly in the C compiler.
From .c file it will include one .h file, and from that .h file another .h file is included.
But still i am facing the same issue, Can anyone help me out.
The header i have is like below:
#include <netinet/in.h>
#include <arpa/inet.h>
#include <unistd.h>
#include <signal.h>
//#include <wait.h>
#include <sys/time.h>
#include <sys/socket.h>
#include <sys/types.h>
//#include <ipc.h>
//#include <shm.h>
#include <fcntl.h>
#include <errno.h>
#include <string.h>
#include <stdio.h>
#include <stdlib.h>
#define socklen_t int
/* limit values */
#define MAX_TAGS 500
#define MAX_OBJECTS 500
#include "Protocols.h"
If you really set the correct path in you compiler, you could try to hardcode the path like #include "/path/name.h".
If this works, you have some issue with your compiler and maybe not set the path (the right way).
If this does not work it seems, that the file is not existing or broken in some way. In this case: Get a new version of the headerfile and make sure, that it is in the right place.

Looking for 4psa_base.h header file to recompile app_fax.c

I am trying to recompile app_fax.c to app_fax.so (module used by asterisk to send/receive fax under 4PSA system) which needs a header file called 4psa_base.h
The reason I am recompiling this c program is because of a timeout setting inside the program that kills fax calls that last more than 30 minute. what I did was just change that value
I have looked everywhere for this file with no luck. its not anywhere that I can find it.
Is there anyone that may have any clue where to find this file?
Thanks,
Javid
I'm not sure which version of Asterisk you are using, but app_fax (which is not the preferred fax module in Asterisk) depends on spandsp. Looking at the source, it does not include the header file you're referring to:
ASTERISK_FILE_VERSION(__FILE__, "$Revision$")
#include <string.h>
#include <stdlib.h>
#include <stdio.h>
#include <inttypes.h>
#include <pthread.h>
#include <errno.h>
#include <tiffio.h>
#define SPANDSP_EXPOSE_INTERNAL_STRUCTURES
#include <spandsp.h>
#include <spandsp/version.h>
#include "asterisk/lock.h"
#include "asterisk/file.h"
#include "asterisk/logger.h"
#include "asterisk/channel.h"
#include "asterisk/pbx.h"
#include "asterisk/app.h"
#include "asterisk/dsp.h"
#include "asterisk/module.h"
#include "asterisk/stasis.h"
#include "asterisk/stasis_channels.h"
#include "asterisk/format_cache.h"
Is this a custom patch to Asterisk?

Resources