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 08-07-2003, 02:40 PM   #1
DarkDrive
LQ Newbie
 
Registered: Jul 2003
Location: Albuquerque, NM
Distribution: MDK 9.1
Posts: 24

Rep: Reputation: 15
C syntax help please ...


I'm trying to make bash, and I'm getting the following:

mkbuiltins.c:1430: argument `from' doesn't match prototype
/usr/lib/gcc-lib/i586-mandrake-linux-gnu/3.2.2/include/stdio.h:163: prototype declaration

mkbuiltins.c contains the following:

static int
rename (from, to)
char *from, *to;
{
unlink (to);
if (link (from, to) < 0)
return (-1);
unlink (from);
return (0);
}

as well as:

static int rename (char, char);

at the top. Incendently, I've tried commenting this out b/c the compiler was saying it didn't match the prototype.

And the stdio.h contains the following:

163 extern int rename (__const char *__old, __const char *__new) __THROW;

I don't really understand the syntax for this. Is there a simple answer to making this compile?

Thanks much!
 
Old 08-07-2003, 03:19 PM   #2
shishir
Member
 
Registered: Jul 2003
Location: bangalore . india
Distribution: openSUSE 10.3
Posts: 251

Rep: Reputation: 33
this is a pretty basic error..

when you do a static definition of the function "rename", you are creating problems because the prototype from the header stdio.h says the parameters are const char* and not char *(that you have written) ..and you should also
change it to const char* for the sake of posterity...(you are not going to modify the incoming parameters..right???)...

this, while would remove the error, would still give you a warning for static defintion and extern declaration..not quite a mix....
solution : either remove the static itself..would remove all warnings

as for the __THROW__ part in the prototype in the header..
this is for use in C++, where this macro expands to throw(), for throwing exceptions


A SUGGESTION: if you are the allowed to give your own function names, then it would be better if you did not use the standard function names..it creates more confusion than easing things out

Last edited by shishir; 08-07-2003 at 03:25 PM.
 
Old 08-07-2003, 04:13 PM   #3
DarkDrive
LQ Newbie
 
Registered: Jul 2003
Location: Albuquerque, NM
Distribution: MDK 9.1
Posts: 24

Original Poster
Rep: Reputation: 15
Thank you sir. I renamed the function (it's not called from anywhere else) and made the signatures match.
 
  


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
syntax SmithSmith123 Linux - Newbie 2 11-17-2005 04:45 PM
Help with syntax dr3vi1 Linux - Newbie 7 08-09-2005 10:20 AM
Help with lp syntax slick_willie Programming 2 02-03-2005 07:18 PM
C++ syntax error before :: token HELP, i cant find the syntax error :( qwijibow Programming 2 12-14-2004 06:09 PM
syntax lynger Linux - Software 6 12-02-2003 01:03 AM

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

All times are GMT -5. The time now is 06:45 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
Open Source Consulting | Domain Registration