LinuxQuestions.org
Visit the LQ Articles and Editorials section
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 10-26-2003, 11:01 AM   #1
h/w
Senior Member
 
Registered: Mar 2003
Location: New York, NY
Distribution: Debian Testing
Posts: 1,286

Rep: Reputation: 45
what is this warning in C?


hey - these are some warnings i get and i would like to not see them when i code. it doesnt affect the running of the code, but stilll ...

Code:
implicit declaration of function 'strrchr'
that;s when i write some line like
Code:
char *end, *line;
if ( (end = strrchr (line, ':')) == NULL)
thank you very much again.

Last edited by h/w; 10-26-2003 at 11:02 AM.
 
Old 10-26-2003, 01:01 PM   #2
Y0jiMb0
Member
 
Registered: Jul 2003
Location: Valencia (Spain)
Distribution: slackware 11, FEDORA CORE 4, RHEL3, Gentoo...
Posts: 361

Rep: Reputation: 30
...and, of course, you've added
Code:
#include <string.h>
at the beginning of the program, haven't you?
Regards
 
Old 10-26-2003, 02:03 PM   #3
h/w
Senior Member
 
Registered: Mar 2003
Location: New York, NY
Distribution: Debian Testing
Posts: 1,286

Original Poster
Rep: Reputation: 45
of course.
 
Old 10-26-2003, 04:04 PM   #4
megaspaz
Senior Member
 
Registered: Nov 2002
Location: Silly Con Valley
Distribution: Red Hat 7.3, Red Hat 9.0
Posts: 2,054

Rep: Reputation: 46
well your pointers aren't initialized. to you, they look like they're pointing to nowhere, but in reality, where they point to is undefined. they could be pointing to anywhere. always initialize your pointer variables to some value before using them in checks, pointer arithmetic, etc.

not sure about the warning though, if you say <string.h> is included.
 
Old 10-26-2003, 05:12 PM   #5
Robert0380
Guru
 
Registered: Apr 2002
Location: Atlanta
Distribution: Gentoo
Posts: 1,280

Rep: Reputation: 47
u must be compiling with -ansi huh?

put a prototype in for strchrr and that might clear it up. same happens with strdup
 
Old 10-26-2003, 11:30 PM   #6
SaTaN
Member
 
Registered: Aug 2003
Location: Suprisingly in Heaven
Posts: 223

Rep: Reputation: 32
Code:
#include<string.h>
#include<stdio.h>
main()
{
        char *end,*line="This is a :test";
        if((end=strchr(line,':'))!=NULL)
                printf("%s\n",end);
}
[SaTaN@mirage linux_org]$ cc strchr.c
[SaTaN@mirage linux_org]$ ./a.out
:test


This works fine on my machine.Maybe you should post the entire code.
 
Old 10-27-2003, 12:05 AM   #7
h/w
Senior Member
 
Registered: Mar 2003
Location: New York, NY
Distribution: Debian Testing
Posts: 1,286

Original Poster
Rep: Reputation: 45
thanks guys - all of y'all.
as i mentioned, it doesnt affect the running of the code. the message only comes up when i compile with -Wall. it doesnt come up with a "gcc -o test test.c".
thanks again.
 
Old 10-27-2003, 12:16 AM   #8
Robert0380
Guru
 
Registered: Apr 2002
Location: Atlanta
Distribution: Gentoo
Posts: 1,280

Rep: Reputation: 47
put in the prototype anyway!!! (all it will do is pass Wall and it will also help it lint with no errors).
 
  


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


Similar Threads
Thread Thread Starter Forum Replies Last Post
ld: warning drand Linux - Software 2 05-25-2010 05:03 AM
Warning for Newbies !! raceware Linux - Distributions 24 03-01-2004 02:30 PM
perl warning lenlutz Red Hat 1 01-31-2004 10:18 AM
why warning message is appear? eye Red Hat 3 10-22-2003 10:14 AM
fstab warning Gordon Slackware 5 04-15-2003 05:41 PM


All times are GMT -5. The time now is 11:07 AM.

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