Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 418217
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 12, 20262026-05-12T18:39:25+00:00 2026-05-12T18:39:25+00:00

When I compile the following code: #define _POSIX_C_SOURCE 200112L #define _ISOC99_SOURCE #define __EXTENSIONS__ #include

  • 0

When I compile the following code:

#define _POSIX_C_SOURCE 200112L
#define _ISOC99_SOURCE
#define __EXTENSIONS__

#include <stdio.h>
#include <limits.h>
#include <stdlib.h>    

int
main(int argc, char *argv[])
{
    char *symlinkpath = argv[1];
    char actualpath [PATH_MAX];
    char *ptr;
    ptr = realpath(symlinkpath, actualpath);
    printf("%s\n", ptr);
}

I get a warning on the line that contains the call to the realpath function, saying:

warning: assignment makes pointer from integer without a cast

Anybody know what’s up? I’m running Ubuntu Linux 9.04

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-12T18:39:26+00:00Added an answer on May 12, 2026 at 6:39 pm

    This is very simple. Glibc treats realpath() as a GNU extension, not POSIX. So, add this line:

    #define _GNU_SOURCE
    

    … prior to including stdlib.h so that it is prototyped and known to to return char *. Otherwise, gcc is going to assume it returns the default type of int. The prototype in stdlib.h is not seen unless _GNU_SOURCE is defined.

    The following complies fine without warnings with -Wall passed:

    #include <stdio.h>
    #include <limits.h>
    
    #define _GNU_SOURCE
    #include <stdlib.h>
    
    int
    main(int argc, char *argv[])
    {
        char *symlinkpath = argv[1];
        char actualpath [PATH_MAX];
        char *ptr;
        ptr = realpath(symlinkpath, actualpath);
        printf("%s\n", ptr);
    
        return 0;
    }
    

    You will see similar behavior with other popular extensions such as asprintf(). Its worth a look at /usr/include/ to see exactly how much that macro turns on and what it changes.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

How does the following code compile correctly, #include <stdio.h> #define stringer( x ) printf_s(
The following code using boost::asio will not compile: #ifndef _SERVER_H_ #define _SERVER_H_ #include Connection.h
I have the following code which is failing to compile. #include <stdio.h> #include <log4cpp/Category.hh>
I get Compiler Error C2248 when i try to compile the following code: #include
I have the following code: int main(void) { struct { int x; } a,
I have the following code #define PROC_ADD void main(void) { while(1) { #ifdef PROC_ADD
I can't compile the following code using g++ 4.1.2: #include <memory> class A {
I'm trying to compile the following snippet of code: #include <boost/filesystem/path.hpp> //Other includes snipped
The problem I have is illustrated in the following code. #include <iostream> #define X
I have the following libev code: #include <ev.h> #include <stdio.h> #include <errno.h> #include <sys/socket.h>

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.