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 3301090
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 17, 20262026-05-17T20:43:10+00:00 2026-05-17T20:43:10+00:00

I maintain an open source program that builds with autoconf. Right now I’m having

  • 0

I maintain an open source program that builds with autoconf.

Right now I’m having a problem with some of my users. They are using a pre-distributed VM from an organization that has an incorrect prototype for strchr in it. Their prototype is:

char *strchr(char *,int c);

when of course we know it should be:

char *strchr(const char *s,int c);

(which is itself broken, as the output should really be const char *, but then you couldn’t modify what it gives you if you passed in a char * and not a const char *, but I digress.

My question: is there a way to create an autoconf macro that determines which prototype is in use and use it accordingly? I’d rather not make my code say:

v = strchr((char *)s,c);

Thanks!

  • 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-17T20:43:10+00:00Added an answer on May 17, 2026 at 8:43 pm

    You should be able to set up a configure test that attempts to call the const char* version (NOT using a literal since there’s an implicit conversion to char*). Configure will tell you if it compiled or not so you can #define something based on that and use it to make a decision in your code (preferably in some sort of wrapper/utility class).

    For example something like (untested):

    AC_TRY_COMPILE([#include <cstring>],
     [const char* str = "Test"; strchr(str, 't');],
     conforming_strchr=yes,
     conforming_strchr=no)
    if test "$conforming_strchr" = yes; then
      AC_DEFINE(HAVE_CONFORMING_STRCHR, 1,
       [define to 1 if strchr takes const char*])
    fi
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I maintain an open source python project. Right now it supports python 2.4, 2.5,
I maintain GPSD, a widely-deployed open-source service daemon that monitors GPSes and other geodetic
I maintain 2 identities one for open source development - which doesn't really contain
I maintain an applet that helps users to upload photos to our service. The
need a technology (open source or build myself) usable from C# that allows me
The question An open source program uses CVS for version control. I would like
I'm integrating open source c program with Java program. I'd tried to use JNI
I want to create an open source application for Android that will be available
I have been looking round for an open-source CMS framework that I can use
I manage an open-source project and would like to sign the binaries that are

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.