In Xcode how does one create a header file? and what should it include? or does xcode create the file and use the information from the .c file to create the .h file

Edited by happygeek: moved from Apple forum

4 Years
Discussion Span
Last Post by rubberman

New to C programming are we? You need to learn how C program files use headers to describe/define structures and interfaces. This is basic computer science and programming 101. For example, if I have a C source file that implements some API (functions) that other programs may use, I will create a header file that specifies the signature of the functions (API) so other applications can use them. Example:

#ifndef MY_C_HEADER_H
#define MY_C_HEADER_H

typedef struct {
int int_member1;
char array_member2[100];
} mytype_t;

extern void myfunction(int arg1, const mytype_t* pArg2);
#endif /* MY_C_HEADER_H */

In this case I am defining a structure and making it a proper type (mytype_t), and then I am declaring that my code includes the function myfunction(...), in a manner that other programs can use it if they link to my code.

If you don't understand all of what I am saying here, you have some serious studying to do... :-)

Good luck!

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.