473,806 Members | 2,611 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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++.m oderated. First time posters: Do this! ]
Jul 22 '05 #1
3 43300

"Jason" <ja***********@ btinternet.com> wrote in message
news:bt******** **@hercules.bti nternet.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++.m oderated. 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++.m oderated. 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++.m oderated. 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
1909
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 function' error when calling a routine that's defined in that file.
3
2562
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: ERROR: Could not convert UTF-8 to ISO8859-1 Any way I get around this? CREATE OR REPLACE FUNCTION public.mainframe_description(varchar) RETURNS varchar AS ' my($desc) = @_;
0
1101
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: vResource.add("nothing",1)
4
1557
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
1523
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 wrapper for get viewfinder is: Public Delegate Function prViewFinderCB(ByVal CameraHandle As System.UInt32, ByVal Context As System.UInt32, ByVal Size As System.UInt32, ByRef pVFData As IntPtr) As System.UInt32 'C++ doe:
3
1274
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 aggregate function error message. My SQL looks like this: SELECT Count(*) AS Expr1, .Region, Stipulations. FROM INNER JOIN Stipulations ON . = Stipulations. WHERE (((.Region)="North Central") AND ((Stipulations.)="Yes")); I'm an inexperienced...
1
1817
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 libSecond.a app.c. It gives( and it should ) multiple declaration error . Is there any
2
1617
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 a course name and instructor name GradeBook gradeBook( "CS101 Introduction to C++ Programming" );
7
16347
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 on the other domain. Other functions work on the other domain like get all the users and get all the groups and I can validate users on the other domain so I think I am communciating with the other domain OK just not with the...
0
9719
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
9598
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10371
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
0
10111
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 protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
9192
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
0
5546
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
1
4330
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
3852
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
3010
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.