LinuxQuestions.org
Welcome to the most active Linux Forum on the web.
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
 
LinkBack Search this Thread
Old 01-26-2012, 09:37 AM   #1
JonathanWilson
Member
 
Registered: Aug 2009
Location: Ilkeston, England
Distribution: ubuntu, xp, embeded
Posts: 74

Rep: Reputation: 1
c function defined in header, cant find implementation in c files!


I'm trying to find a bug within u-boot and have downloaded the source, but I'm only a beginner in c code so am stuck with a question!

In a file called common.h there is a defined function called puts...

Code:
/* stdout */
void	putc(const char c);
void	puts(const char *s);
int	printf(const char *fmt, ...)
		__attribute__ ((format (__printf__, 1, 2)));
int	vprintf(const char *fmt, va_list args);
The above header file is included in numerous c files... the one I'm interested in is cmd_i2c.c

In the file there is lots of code that uses puts to print various bits of data...

Code:
	/*
	 * memaddr is the address where to store things in memory
	 */
	memaddr = (u_char *)simple_strtoul(argv[4], NULL, 16);

	if (i2c_read(chip, devaddr, alen, memaddr, length) != 0) {
		puts ("Error reading the chip.\n");
		return 1;
	}
	return 0;
Where I'm stuck is I can't find where, or if, puts is actually implimented so my questions are.

Does the c language require a function that is defined in a header and used within the c code to be implimented?

If not, I guess I could code it within the cmd_i2c.c to call printf which should then allow me to see the output on the serial.

If it does have to be implimented then can someone help me find out where it is, or give me pointers on how to find its code.
 
Old 01-26-2012, 10:04 AM   #2
JonathanWilson
Member
 
Registered: Aug 2009
Location: Ilkeston, England
Distribution: ubuntu, xp, embeded
Posts: 74

Original Poster
Rep: Reputation: 1
Managed to find the code, I hacked an implimentation in i2c and when I compiled it it complained that it conflicted with

Code:
console.c:409: multiple definition of `puts'
cmd_i2c.o:/home/wilsonjonathan/pandaboard/Salveti-uboot/u-boot-linaro-stable/common/cmd_i2c.c:138: first defined here
It seems that console.c does some work normally done by stdout.
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

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
Trackbacks are Off
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Can not find header files to use kmalloc() yousafsajjad Programming 23 06-29-2010 11:12 PM
LXer: Implementation-defined (Not really) LXer Syndicated Linux News 0 03-12-2008 04:37 PM
C++: How to have predefined function parameters in source and header files... RHLinuxGUY Programming 22 03-12-2007 10:14 AM
class declared in lib, defined in implementation (C++) ta0kira Programming 6 09-29-2006 07:10 AM
how to find the header files in c compiler ss100 Linux - Software 2 12-12-2004 11:04 PM


All times are GMT -5. The time now is 03:06 PM.

Main Menu
 
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
identi.ca: @linuxquestions
Facebook: @linuxquestions
Open Source Consulting | Domain Registration