LinuxQuestions.org
Help answer threads with 0 replies.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.

Notices


Reply
  Search this Thread
Old 05-18-2011, 05:21 PM   #1
Fritz_Doll
LQ Newbie
 
Registered: Dec 2010
Posts: 20

Rep: Reputation: Disabled
use typedef from another file - C


I want to use a typedef defined in another file, but not sure how to do this; would also like to do the same thing for enums. How do I go about doing this?
main.c
Code:
void main(){
...
//Create DATA type variables here
DATA d1;
DATA d2;
...
}
second.c
Code:
struct dat{
int var1;
int var2;
};
typedef struct data DATA;
 
Old 05-18-2011, 05:54 PM   #2
paulsm4
LQ Guru
 
Registered: Mar 2004
Distribution: SusE 8.2
Posts: 5,863
Blog Entries: 1

Rep: Reputation: Disabled
Assuming you're using C/C++, it sounds like a job for a header file, e.g.
Code:
#include "my_defs.h"
 
Old 05-18-2011, 06:16 PM   #3
Fritz_Doll
LQ Newbie
 
Registered: Dec 2010
Posts: 20

Original Poster
Rep: Reputation: Disabled
Thanks, helped point me in the right direction. Very useful thing to know.
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
typedef in C Oaks Programming 1 08-05-2009 09:49 AM
A little 'typedef' problem SpLaSh212 Programming 3 12-07-2008 09:52 AM
[C] The FAR in typedef koyi Programming 2 07-21-2006 07:37 PM
having problem with typedef TurtleFace Programming 4 03-30-2006 09:18 PM
Can you help me with typedef? brownstone Programming 3 06-11-2004 10:09 AM

LinuxQuestions.org > Forums > Non-*NIX Forums > Programming

All times are GMT -5. The time now is 11:43 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration