473,396 Members | 1,871 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,396 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 7341
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: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...

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.