How to declare a typedef in a header file for many other c files to use it?
I'm spiting up this one C file into many, putting all of the functions into a separate c file with its header and creating other c file with there headers and they all are in need to use the data within the typedef within the functions.
1. where would be the best C file to put that typedef in, if that can even be answered. 2. how to define it then make it usable to all other c files? I actually have two to deal with. Code:
Code:
serx%slackwhere â¡ LearningVDTinC â¡> gcc -m64 -lX11 `imlib2-config --cflags` `imlib2-config --libs` mhsetrootV2.c vdt.c displayimage.c -o setroots |
You need to name your struct, and can you give some code or come with some example code that would use these definitions? Just giving the errors isn't particularly helpful.
|
Quote:
I put the two into a header, then with that function call Code:
#typedef struct |
I don't know why you're using a pound sign, it's something like this:
Code:
Code:
1 2 Hello, World! |
Ok everything is working again.
|
Quote:
Code:
typedef struct Color { Code:
int getHex (char c) |
Your question reduces to this...
Quote:
To make any such definition visible to other code segments at compile-time, it must simply be included before it is referenced. The posted code and error messages are not directly relevant to the question being asked. I know that you want to ask complete questions, but please try to limit your code and data examples to well considered, minimal snippets which exactly illustrate a specific point. It takes time and energy for others to read through the extra bits, only to discover that they are not relevant. Also, when posting command examples please do not include your personalized prompt string in command examples. Your eye recognizes and ignores it, but others must visually parse every single line just to find the beginning of the actual command. Code:
serx%slackwhere âš¡ LearningVDTinC âš¡> gcc -m64 -lX11 `imlib2-config --cflags` `imlib2-config --libs` mhsetrootV2.c vdt.c displayimage.c -o setroots |
Quote:
|
Quote:
|
Quote:
Code:
mhsetrootV2.c:488:37: error: unknown type name 'ImageMode' Code:
typedef enum first question: Code:
1. where would be the best C file to put that typedef in, Code:
The best place depends entirely on how you have organized, or not, your code. Some yes that prompt looked crapy and perhaps was too much to look at. |
Quote:
#include #define #ifdef #ifndef etc... So it's not very wise to use it for a totally different meaning mixed in with C code. |
All times are GMT -5. The time now is 12:10 PM. |