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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 30, 20262026-05-30T09:04:25+00:00 2026-05-30T09:04:25+00:00

How (in GCC/GNU C) do you declare a function pointer which points to an

  • 0

How (in GCC/”GNU C”) do you declare a function pointer which points to an __attribute__((const)) function? The idea being that I want the compiler to avoid generating multiple calls to the function called through the function pointer when it can cache the return value from a previous call.

  • 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-30T09:04:26+00:00Added an answer on May 30, 2026 at 9:04 am
    typedef void (*t_const_function)(void) __attribute__((const));
    
    static __attribute__((const)) void A(void) {
    }
    
    static void B(void) {
    }
    
    int main(int argc, const char* argv[]) {
        t_const_function a = A;
    
        // warning: initialization makes qualified
        // function pointer from unqualified:
        t_const_function b = B;
    
        return 0;
    }
    

    Or just:

    __attribute__((const)) void(*a)(void) = A;
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I want to compile GCC and binutils which would produce 64bit executables. From GNU
This page says that GCC 4.5 has C++ raw string literals: http://gcc.gnu.org/projects/cxx0x.html But when
How do I install GCC (the GNU Compiler Collection) piece by piece, using the
http://gcc.gnu.org/onlinedocs/gcc-4.4.2/gcc/Atomic-Builtins.html I believe that the following code increases the value of var atomically. volatile
http://gcc.gnu.org/onlinedocs/gcc-2.95.3/objc-features_1.html#SEC2 The GNU Objective-C runtime provides a way that allows you to execute code
So I was reading http://gcc.gnu.org/onlinedocs/gcc-4.1.0/gcc/Atomic-Builtins.html , and came across this: type __sync_and_and_fetch (type *ptr,
GNU gcc 4.3 partially supports the upcoming c++0x standard: among the implemented features the
I do the following in command line: 1) wget ftp://mirrors.kernel.org/gnu/gcc/gcc-3.4.6/gcc-3.4.6.tar.bz2 2) tar -jxf gcc-3.4.6.tar.bz2
GCC compiles (using gcc --omit-frame-pointer -s ): int the_answer() { return 42; } into
GCC is a very well respected multi-language compiler (from what I've gathered). One thing

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.