LinuxQuestions.org
Review your favorite Linux distribution.
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 04-03-2007, 09:38 AM   #1
haxpor
Member
 
Registered: Dec 2006
Distribution: Ubuntu 20.04
Posts: 87

Rep: Reputation: 15
lib/*.c use in main.c without include the header.


Here is situation for my question:

main.c => is sourcecode for the program.
header.h => is header file that main.c include
|_ func1() exist in header.h but it is defined only for Prototype like this 'void func1(void);', which header.h doesn't define what func1() do,not at all.

lib/sumfunc.c => is the sourcecode for func1(), this time it define what func1() do.

-------------------

SO this is question, I want to know that how can 'main.c' use 'func1()' that defined only prototype in 'header.h' but its work is define in 'lib/sumfunc.c'.
How can we tell the compiler to know that?
I want to know the step to do that.

Thanks in advance.
 
Old 04-04-2007, 02:28 AM   #2
slzckboy
Member
 
Registered: May 2005
Location: uk - Reading
Distribution: slackware 14.2 kernel 4.19.43
Posts: 462

Rep: Reputation: 30
Code:
gcc -o sumprogram main.c lib/sumfunc.c
in main.c and sumfunc.c you need to do

#define "header.h"

if the header files are in the build directory

or

#define <header.h>

if you have put it with the rest of your system header files.
 
Old 04-04-2007, 09:50 AM   #3
haxpor
Member
 
Registered: Dec 2006
Distribution: Ubuntu 20.04
Posts: 87

Original Poster
Rep: Reputation: 15
Thanks slzckboy.
 
  


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
unable to include header file.. nick021 Programming 2 05-05-2006 03:11 PM
Include Custom Header Kenji Miyamoto Programming 3 01-13-2005 08:46 PM
header include path KDE4me Linux - Newbie 6 01-06-2005 06:17 AM
Problem with C++ include/header files! Pisces107 Programming 12 12-23-2003 11:06 PM
include and lib paths Mux Slackware 1 05-05-2002 09:06 PM

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

All times are GMT -5. The time now is 02:29 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