Talk About Network

Google





Programming > C - C++ Learning > Re: Using the s...
Latest [ Topics | Posts ] Archive Post A New Topic Post a Reply
<< Topic < Post Post 12 of 22 Topic 4074 of 4400
Post > Topic >>

Re: Using the same source file from other source files

by Ben Bacarisse <ben.usenet@[EMAIL PROTECTED] > Mar 20, 2008 at 03:08 PM

Hal Vaughan <hal@[EMAIL PROTECTED]
> writes:

> Hal Vaughan wrote:
>
>> Hal Vaughan wrote:
> ...
>> There's one problem that didn't show up until I fixed this one.
>> 
>> I have my own library with this function:
>> 
>> void parseargs(int, char*);

This declaration does not match the definition you give later.
 
>> I call it from the main function with argc and argv.

The the second parameter should be char **...

>  When I've compiled
>> this without using make there was no problem, but now that I'm using
make
>> (or compiling it by hand, with the changes make needed), I get this
error:
>
> I die a make clean and tried again and this would be the correct error:
>
> hdcmd.cpp: In function ?int main(int, char**)?:
> hdcmd.cpp:35: error: cannot convert ?char**? to ?char*? for argument
> ?2?

as diagnosed by the compiler!

<snip>
> And here's the function definition:
>
> map<string,string> parseargs(int count, char* args[]) {
> ....
> }

Above, you declared it as returning void and taking a char *.  You
can't lie to the compiler and get away with it for long.  You need to
#include the header that declares parseargs in the file source that
defines it as well.  That way, you get a check that the declaration
matches the definition.  If the definition is in the same file, you
still need to make sure the two match up.

-- 
Ben.
 




 22 Posts in Topic:
Using the same source file from other source files
Hal Vaughan <hal@[EMAI  2008-03-20 07:10:47 
Re: Using the same source file from other source files
Richard Heathfield <rj  2008-03-20 07:25:59 
Re: Using the same source file from other source files
Hal Vaughan <hal@[EMAI  2008-03-20 07:29:28 
Re: Using the same source file from other source files
"Jim Langston"   2008-03-20 00:55:37 
Re: Using the same source file from other source files
Philip Potter <pgp@[EM  2008-03-20 15:31:49 
Re: Using the same source file from other source files
Richard Heathfield <rj  2008-03-20 08:36:26 
Re: Using the same source file from other source files
Hal Vaughan <hal@[EMAI  2008-03-20 08:50:25 
Re: Using the same source file from other source files
Hal Vaughan <hal@[EMAI  2008-03-20 09:28:25 
Re: Using the same source file from other source files
Hal Vaughan <hal@[EMAI  2008-03-20 09:37:01 
Re: Using the same source file from other source files
"Chris ( Val )"  2008-03-21 03:37:07 
Re: Using the same source file from other source files
Philip Potter <pgp@[EM  2008-03-25 17:22:35 
Re: Using the same source file from other source files
Ben Bacarisse <ben.use  2008-03-20 15:08:23 
Re: Using the same source file from other source files
Hal Vaughan <hal@[EMAI  2008-03-20 15:37:26 
Re: Using the same source file from other source files
Ben Bacarisse <ben.use  2008-03-20 15:48:02 
Re: Using the same source file from other source files
Hal Vaughan <hal@[EMAI  2008-03-20 15:56:20 
Re: Using the same source file from other source files
Philip Potter <pgp@[EM  2008-03-20 17:11:20 
Re: Using the same source file from other source files
Hal Vaughan <hal@[EMAI  2008-03-20 17:54:57 
Re: Using the same source file from other source files
Philip Potter <pgp@[EM  2008-03-21 10:03:58 
Re: Using the same source file from other source files
Ben Bacarisse <ben.use  2008-03-20 19:34:41 
Re: Using the same source file from other source files
Hal Vaughan <hal@[EMAI  2008-03-20 20:31:21 
Re: Using the same source file from other source files
Ben Bacarisse <ben.use  2008-03-20 19:45:49 
Re: Using the same source file from other source files
Hal Vaughan <hal@[EMAI  2008-03-20 20:34:08 

Post A Reply:
  Go here to Signup

AddThis Feed Button


About - Advertising - Contact - Frequently Asked Questions - Privacy Policy - Terms of Use - Signup

Contact
localhost-V2008-12-19 Wed Jan 7 12:16:54 PST 2009.