472,995 Members | 1,820 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 472,995 software developers and data experts.

question: typedef's do they belong in header file or in .c files ?

Hello,

I have a question regarding type definitions. I usually put them in
header files. But I recently came over several discussions on the www.
And now I'm not to sure anymore if they go in .c file or in the header
files ?

What would be the correct way ?

Thank you.

Jas.
Nov 14 '07 #1
2 7308
On Nov 13, 6:59 pm, jason <ji...@notmal.comwrote:
Hello,

I have a question regarding type definitions. I usually put them in
header files. But I recently came over several discussions on the www.
And now I'm not to sure anymore if they go in .c file or in the header
files ?

What would be the correct way ?
Header files are for sharing. If you need visibility of the typedef
across two or more source modules, put it in a header file. If the
typedef is used in only one source module, put it there.

Regards,

-=Dave
Nov 14 '07 #2

"jason" <ji***@notmal.comwrote in message
news:47**********************@dreader23.news.xs4al l.nl...
Hello,

I have a question regarding type definitions. I usually put them in
header files. But I recently came over several discussions on the www.
And now I'm not to sure anymore if they go in .c file or in the header
files ?

What would be the correct way ?

Thank you.
IMO, headerers are better.

this is also especially true in my case since I tend to use tools to
autogenerate the headers (function prototypes and so on), and so, not having
types in headers can make a very big mess with said autogenerated
prototypes...

Jas.

Nov 14 '07 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

16
by: Vu Pham | last post by:
I think this problem relates to either c or c++ ( but I am not sure which one ) so I post to both of these news group. I am sorry if I did something wrong here. Is there any difference between...
7
by: Morenz | last post by:
Hi all, I've got a problem with a struct, well i want to declare struct in main program ( in .c file ) and then use it in a librarie included file( .h file ), is it possible? Thank in advance...
4
by: QQ | last post by:
Here is my program the head is typedef struct struct_CN { unsigned char magicA; unsigned char magicB; unsigned short msgLen; } CN;
16
by: burn | last post by:
Hello, i am writing a program under linux in c and compile my code with make and gcc. Now i have 4 files: init.c/h and packets.c/h. Each header-file contains some: init.h: struct xyz {
7
by: Dennis Myrén | last post by:
Hi. Is there any way to define an alias for a type like you could in C++: typedef int NUMBER; I tried using #define but that did not work. Thank you. -- Regards,
12
by: spibou | last post by:
I have two identical files , u1.c and u2.c which only contain the line typedef int Q ; When I issue "splint u1.c u2.c" I get u2.c:1:13: Datatype Q defined more than once A function or variable...
2
by: toonces | last post by:
I am doing cross compiling between C++ and C compiler for header files and desperately need help on figuring out namespace issue error generated by C++ compiler. Here are two header files:abc1.h,...
12
by: Bryan Parkoff | last post by:
I write my large project in C++ source code. My C++ source code contains approximate four thousand small functions. Most of them are inline. I define variables and functions in the global scope....
2
by: zeeshan708 | last post by:
I am quoting this from Deitel's 5th edition on C++ Now the question is... Why is there a separate specialization for char data type ??? Is it because the files normally are made up of...
0
by: lllomh | last post by:
Define the method first this.state = { buttonBackgroundColor: 'green', isBlinking: false, // A new status is added to identify whether the button is blinking or not } autoStart=()=>{
0
by: Aliciasmith | last post by:
In an age dominated by smartphones, having a mobile app for your business is no longer an option; it's a necessity. Whether you're a startup or an established enterprise, finding the right mobile app...
2
by: giovanniandrean | last post by:
The energy model is structured as follows and uses excel sheets to give input data: 1-Utility.py contains all the functions needed to calculate the variables and other minor things (mentions...
4
NeoPa
by: NeoPa | last post by:
Hello everyone. I find myself stuck trying to find the VBA way to get Access to create a PDF of the currently-selected (and open) object (Form or Report). I know it can be done by selecting :...
3
NeoPa
by: NeoPa | last post by:
Introduction For this article I'll be using a very simple database which has Form (clsForm) & Report (clsReport) classes that simply handle making the calling Form invisible until the Form, or all...
3
by: nia12 | last post by:
Hi there, I am very new to Access so apologies if any of this is obvious/not clear. I am creating a data collection tool for health care employees to complete. It consists of a number of...
0
NeoPa
by: NeoPa | last post by:
Introduction For this article I'll be focusing on the Report (clsReport) class. This simply handles making the calling Form invisible until all of the Reports opened by it have been closed, when it...
0
isladogs
by: isladogs | last post by:
The next online meeting of the Access Europe User Group will be on Wednesday 6 Dec 2023 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, Mike...
3
SueHopson
by: SueHopson | last post by:
Hi All, I'm trying to create a single code (run off a button that calls the Private Sub) for our parts list report that will allow the user to filter by either/both PartVendor and PartType. On...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.