473,513 Members | 4,753 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Compiler error: warning: implicit declaration of function 'strdup'

4 New Member
Hi guys,

When I compile this code, I'm getting the following error:
warning: implicit declaration of function 'strdup'

I've included <string.h> and <wchar.h> so I shouldn't be getting the error right?

The line of code in question is:
Expand|Select|Wrap|Line Numbers
  1. //some declarations inside a static function
  2. simple_path = strdup(path);
  3.  
The part thats confusing me is that I use strdup in other parts of my program, but the compiler isn't complaining about that.

Any help is appreciated.

Thanks
Nov 6 '07 #1
5 7808
Ganon11
3,652 Recognized Expert Specialist
What variable types are path and simple_path?
Nov 6 '07 #2
TalonStriker
4 New Member
What variable types are path and simple_path?
Both are pointers to char.
Nov 6 '07 #3
weaknessforcats
9,208 Recognized Expert Moderator Expert
Post the function. please.
Nov 6 '07 #4
TalonStriker
4 New Member
Post the function. please.
The function doesn't do anything special until that line... here it is

Expand|Select|Wrap|Line Numbers
  1. #include <stdio.h>
  2. #include <stdlib.h>
  3. #include <string.h>
  4. #include <wchar.h>
  5.  
  6. /* some other functions*/
  7.  
  8. static Item * parse(Item * const root, Item * const curr, char * path)
  9. {
  10.     char *simple_path;
  11.     char *a, *b;
  12.     char temp[80] = {0};
  13.     Item * true_item = NULL;
  14.     int finished = 0;
  15.  
  16.     simple_path = strdup(path); //error here
  17. //blah blah
  18.  
Nov 6 '07 #5
TalonStriker
4 New Member
Actually, I need to clarify one thing. I mentioned in my original post that the compiler wasn't complaining about my other uses of strdup. I was incorrect, the compiler (gcc) seems to be assuming that the function is returning an int and is spitting out warnings about assigning an int to a pointer without casting.

However, the compiler isn't complaining about the other uses of functions in string.h
Nov 6 '07 #6

Sign in to post your reply or Sign up for a free account.

Similar topics

3
43287
by: Jason | last post by:
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() {
6
4714
by: Peter Frost | last post by:
Please help I don't know if this is possible but what I would really like to do is to use On Error Goto to capture the code that is being executed when an error occurs. Any help would be much...
5
1957
by: hpy_awad | last post by:
I wrote that example from a book and there is en error in the display module that it does not showing all the records are entered in the input module. I traced with some printf statments without...
10
1720
by: Ivan Vecerina | last post by:
Here's a relatively simple code snippet: #include <memory> class Base { public: Base(); virtual ~Base(); virtual void f(int a, char const* name);
13
504
by: Bill | last post by:
Can someone help me with this error: error C2143: syntax error : missing ';' before 'type' Here is the line it's complaining about: for(int i=0;i<4;i++){ printf("%d",x); }
9
2084
by: Finger.Octopus | last post by:
I dont know whats terribly going wrong with this, well I know there's some memory allocation with this but I tried hard to fix it and when it gets fixed it doesn't shows up the desired value, this...
7
3291
by: i | last post by:
#include<stdio.h> #include<conio.h> #include<process.h> #include<string.h> char ch; int w; int n,m; //void main(); char check(int n,int m,char ch); void cash(int n,int m,char ch);
14
1852
by: 2005 | last post by:
Would it suppress errors? Is he trying to hide errors in his code?
7
70259
by: singhPrabhat | last post by:
Hi, I am using gcc (GCC) 4.2.1 (SUSE Linux). SUSE 10.3 While compiling a .c file I get following error :::: CCWebConfiguration.h:70: error: expected ‘=’, ‘,’, ‘;’, ‘asm’ or...
0
7254
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,...
0
7153
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...
1
7094
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
5677
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,...
1
5079
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
4743
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
0
1585
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 ...
1
796
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
452
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...

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.