Home » C programs

Solution of Warning implicit declaration of function 'getpid' in C

Here, we are going to learn how to fix the issue of “Warning implicit declaration of function 'getpid'” while compiling C program?
Submitted by IncludeHelp, on March 08, 2018

What is implicit declaration of function 'getpid' Warning?

Warning implicit declaration of function 'getpid' - While getting Process Id, this is the common warning which occurs.

Consider the following code snippet

#include <stdio.h>
int main()
    printf("Process Id is: %ld\n",getpid());
    return 0;

See the warning after compiling the program

    warning: implicit declaration of function 'getpid'

This is the same problem, for which you are looking?

Then, what's the solution?

getpid() - is used to get process id of the current process, and it is declared in <unistd.h> header file.

The warning occurs, if you do not include this header file, to fix the warning include <unistd.h> header file in the program.

[SOLVED] Consider the code snippet

#include <stdio.h>
#include <unistd.h>
int main()
    printf("Process Id is: %ld\n",getpid());
    return 0;


    Process Id is: 98

Related program...

C program to get Process Id and Parent Process Id in Linux.

Comments and Discussions

Ad: Are you a blogger? Join our Blogging forum.

Languages: » C » C++ » C++ STL » Java » Data Structure » C#.Net » Android » Kotlin » SQL
Web Technologies: » PHP » Python » JavaScript » CSS » Ajax » Node.js » Web programming/HTML
Solved programs: » C » C++ » DS » Java » C#
Aptitude que. & ans.: » C » C++ » Java » DBMS
Interview que. & ans.: » C » Embedded C » Java » SEO » HR
CS Subjects: » CS Basics » O.S. » Networks » DBMS » Embedded Systems » Cloud Computing
» Machine learning » CS Organizations » Linux » DOS
More: » Articles » Puzzles » News/Updates

© https://www.includehelp.com some rights reserved.