473,394 Members | 1,746 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,394 software developers and data experts.

implicit declaration of function 'int func(...)' error

Hi,

Im running windows xp pro and compiling using dev c++ 4. I have the
following situation:

#include <iostream>
#include <string>
using namespace std;

int main() {
string str;
func(str);
}

void func(string str) {
//do stuff, call some other classes member functions etc
func2(str);
}

void func2(string str) {
//do more stuff
}

It says 2 errors occur with the following output:

7 errormain.cpp
implicit declaration of function `int func(...)'
7 errormain.cpp
warning: cannot pass objects of type `string' through `...'
12 errormain.cpp
implicit declaration of function `int func2(...)'
12 errormain.cpp
warning: cannot pass objects of type `string' through `...'

What am I doing wrong???

Thanks for any help in advance
jason

[ See http://www.gotw.ca/resources/clcm.htm for info about ]
[ comp.lang.c++.moderated. First time posters: Do this! ]
Jul 22 '05 #1
3 43280

"Jason" <ja***********@btinternet.com> wrote in message
news:bt**********@hercules.btinternet.com...
Hi,

Im running windows xp pro and compiling using dev c++ 4. I have the
following situation:

#include <iostream>
#include <string>
using namespace std;
void func(string str);
void func2(string str);

int main() {
string str;
func(str);
}

void func(string str) {
//do stuff, call some other classes member functions etc
func2(str);
}

void func2(string str) {
//do more stuff
}

It says 2 errors occur with the following output:

7 errormain.cpp
implicit declaration of function `int func(...)'
7 errormain.cpp
warning: cannot pass objects of type `string' through `...'
12 errormain.cpp
implicit declaration of function `int func2(...)'
12 errormain.cpp
warning: cannot pass objects of type `string' through `...'

What am I doing wrong???


Or you could try rearranging the code:

#include <iostream>
#include <string>
using namespace std;

void func2(string str) {
//do more stuff
}

void func(string str) {
//do stuff, call some other classes member functions etc
func2(str);
}

int main() {
string str;
func(str);
}
Regards,
Sumit.

[ See http://www.gotw.ca/resources/clcm.htm for info about ]
[ comp.lang.c++.moderated. First time posters: Do this! ]
Jul 22 '05 #2
Hello,

"Jason" <ja***********@btinternet.com> writes:
#include <iostream>
#include <string>
using namespace std; int main() {
string str;
func(str);
} void func(string str) {
//do stuff, call some other classes member functions etc
func2(str);
} void func2(string str) {
//do more stuff
} It says 2 errors occur with the following output: 7 errormain.cpp
implicit declaration of function `int func(...)'
The declaration and/or definition of func must come before its first use.
The solution is to either put the entire definition in front of main or to
leave it at its current position but then you have to put

void func(string);

before the first use of func.
7 errormain.cpp
warning: cannot pass objects of type `string' through `...'
This error will disappear after you fixed the previous one.
12 errormain.cpp
implicit declaration of function `int func2(...)'
Same as previous error. func2 should be declared and/or defined before
first use.
12 errormain.cpp
warning: cannot pass objects of type `string' through `...'


Good luck and a happy 2004,
Chris Dams

[ See http://www.gotw.ca/resources/clcm.htm for info about ]
[ comp.lang.c++.moderated. First time posters: Do this! ]
Jul 22 '05 #3


Jason schrieb:
Hi,

Im running windows xp pro and compiling using dev c++ 4. I have the
following situation:

#include <iostream>
#include <string>
using namespace std;

int main() {
string str;
func(str);
}

void func(string str) {
//do stuff, call some other classes member functions etc
func2(str);
}

void func2(string str) {
//do more stuff
}

It says 2 errors occur with the following output:

7 errormain.cpp
implicit declaration of function `int func(...)'


Not a particular useful error message for inexperienced users.

The problem is at the point you call "func" in main and "func2" in func,
these functions are not known to the compiler yet.

Add these 2 lines before main (to declare "func" and "func2"), and
everything should compile fine:

void func(string str);
void func2(string str);
BTW, why do you pass the std::string by value? Usually, it is passed as
const reference (for efficiency reasons).
regards,

Thomas

[ See http://www.gotw.ca/resources/clcm.htm for info about ]
[ comp.lang.c++.moderated. First time posters: Do this! ]
Jul 22 '05 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

6
by: Puzzled | last post by:
This is a weird problem, but perhaps someone else has seen it before (I hope!) If I use a fully qualified include call include ( 'http://localhost/subtree/filename.php') I get an 'undefined...
3
by: Patrick Hatcher | last post by:
Trying to create a plperl function to strip non-friendly mainframe characters from a string. However, when I try to add the Trademark symbol (â„¢) as a replace criteria, PG spits back an error:...
0
by: Jon Paal | last post by:
why is there a declaration error on line 24 ? Compiler Error Message: BC30188: Declaration expected. Source Error: Line 22: Line 23: Dim vResource As New Collection Line 24: ...
4
by: Corno | last post by:
Hi all, I thought that the 2 following functions would have the same effect; void first() { ClassA a("bla"); anotherFunction(a); }
3
by: =?Utf-8?B?RmFyc2Fk?= | last post by:
Hi I have a dll file (PRSDK.dll) for canon camera sdk and wish create a wrapper and sample program for this in vb.net. I create a class (PSReCWrap) and declared wrapper in this. my function in...
3
by: cpanthro | last post by:
Hello, I'm using Access on XP and I am trying to count the number of cases in a Table via a query using two criteria. The criteria are being drawn from two different tables. I keep getting an...
1
by: Raman | last post by:
Hi All, I have two libs (libFirst.a and libSecond.a). Both libs contains a common function func(). Now I want to link an application "app" with these two libs as gcc -o app libFirst.a...
2
by: adrix7 | last post by:
hi, been having error "member function error" i really dont know what to do, please help. I've typed the error in Bold.. thanks guys/gals! int yes1; // create a GradeBook object; pass...
7
by: =?Utf-8?B?SmVycnkgQw==?= | last post by:
I am using this code to get groups for a user and getting a error (5) on the GetAuthorizationGroups() function . There are two domains. This function works on the local domain but does not work...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.