Like Tree1Likes
  • 1 Post By Malcolm McLean

accessing static functions in header via macro

This is a discussion on accessing static functions in header via macro within the C Programming forums, part of the General Programming Boards category; Just wandering, will something like this work? header Code: #define func(arg) func_(arg) ... static void func_(arg); code Code: #include "header" ...

  1. #1
    Registered User
    Join Date
    Aug 2012
    Posts
    20

    accessing static functions in header via macro

    Just wandering, will something like this work?


    header
    Code:
    #define func(arg) func_(arg)
    
    ...
    
    static void func_(arg);
    code
    Code:
    #include "header"
    
    int main()
    {
        func(arg);
    }
    Last edited by wirmius; 05-11-2013 at 06:46 AM.

  2. #2
    Registered User
    Join Date
    May 2012
    Posts
    333
    No. static is essentially an instruction to the linker not to export the symbol from the file in which it is defined. You can't defeat it by a #define, which is processed much earlier (think of the preprocessor as issuing only word processing instructions).
    wirmius likes this.
    I'm the author of MiniBasic: How to write a script interpreter and Basic Algorithms
    Visit my website for lots of associated C programming resources.
    http://www.malcolmmclean.site11.com/www

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. macro functions console appi
    By In_Control001 in forum C Programming
    Replies: 2
    Last Post: 02-17-2010, 02:22 PM
  2. An array of macro functions?
    By someprogr in forum C Programming
    Replies: 6
    Last Post: 01-28-2009, 06:05 PM
  3. Calling non-static functions on static variables
    By pandu in forum C++ Programming
    Replies: 14
    Last Post: 06-19-2008, 03:07 AM
  4. prob with multiple forms accessing header file
    By silkyt in forum Windows Programming
    Replies: 7
    Last Post: 11-03-2007, 04:14 PM
  5. Static variables and header files
    By drrngrvy in forum C++ Programming
    Replies: 8
    Last Post: 12-02-2006, 12:27 PM

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21