42 questions
3
votes
3
answers
209
views
Is there a way to make a header file, like stdio.h and not include it in the compiler?
I'm trying to make a library and I've found that I need to make a header file, which I did and I have a C file too, which contains the functions.
wprintf.h:
#ifdef WPRINTF
#include <wchar.h>
...
0
votes
1
answer
276
views
When locating C program header/s (.h) program is using. Looking for a certain one. How do you grep output from gcc -H -fsyntax-only source.c?
Quite often one wants to know which header/s (path to programheader.h) your C program is depending on.
You can list all, with the command mentioned below, but what if looking for a certain one from ...
2
votes
1
answer
194
views
Header file is in the wrong location
I wanted to include xf86drmMode.h in my c code, but when I did it says there was an error in the header file as it couldn't find drm.h. It's because there is no drm.h on my system, there's only libdrm/...
1
vote
1
answer
101
views
How to properly specify public and private headers with autotools? (library in C or C++)
I have a library in C which can be built with both autotools and CMake. In CMake, it is possible to define public and private headers (.h), so that the public ones are then installed (to be used in ...
0
votes
0
answers
103
views
Including header file in source file of the same name [duplicate]
Is it required to include the header file in the corresponding source file if they both have the same name ?
Here is an example of what I mean :
main.c
#include <stdlib.h>
#include "display....
2
votes
1
answer
192
views
Generating Ada bindings for C headers (Gem #59) doesn't work any more
When I used this method a few years ago, with Ada from the Ubuntu repository, it worked fine. Now, with my installation from Adacore, not so anymore.
The method consists of 2 commands (time.h as ...
0
votes
2
answers
110
views
Where is it better to include an header?
Should I include my headers in the source file or in the .h?
Is header nesting (header include other headers) bad for any reason? If so, what is the reason?
Is it better to forward declare a struct in ...
2
votes
0
answers
244
views
Export a Go function from a shared library when a C header file included for cgo also defines it
I'm trying to write a OpenVPN plugin in go. OpenVPN provides a interface as C header file.
The header contains a function signature
int openvpn_plugin_open_v3(const int version, struct ...
5
votes
2
answers
4k
views
How to make the Zig build system emit a c-header along with a generated library
Calling zig build-lib -femit-h my_lib_source.zig, a c-header file can be exported for a library written in zig.
How can the same be achieved in build.zig?
Could this be achieved with an option to b....
1
vote
1
answer
101
views
How to write a C header file properly so that a function declared by that header file can be linked without any error?
I am trying to write a C header file in this manner:
// header.h
#ifndef HEADER_H
#define HEADER_H
extern int add(int a, int b);
#endif
// header.c
#include "header.h"
int add(int a, int ...
0
votes
0
answers
488
views
Adding library in CMake with many subfolder
I am starting with the raspberry pi pico and the visual studio code in windows. I am practising with the pico examples coming in the SDK V1.5. What I want to try in this example is to add a new level ...
0
votes
1
answer
307
views
How does `math.h` refer to functions like `sin` or `cos`?
I see a plenty of similar questions, which are duplicates (like 12074147), but most of them are concerned with mathematical functions implementation.
My question is more about C standard headers, like ...
1
vote
1
answer
325
views
struct datatype is defined in the .c file and it is used in the header file while the normal situation has to be the opposite [duplicate]
The definition of struct datatype should be in the header file and not the opposite. This is what I understand while this project does the opposite in this special case. What drive the contributor to ...
-1
votes
1
answer
341
views
tool to compare .h files
I was wondering if there is a tool to compare C header files to the main version of those same files locally. To be more specific I have to compare the macros of the header files from the main version ...
-4
votes
2
answers
1k
views
Is it necessary to include shebang #!/bin/bash in a header file?
There was a requirement to include #!/bin/bash in the first line of all files in a project to create static libraries, but during compilation of the object file, the compiler gave me the message:
In ...