Thread: accessing static functions in header via macro

  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
    505
    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).
    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.
    https://github.com/MalcolmMcLean


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, 03:22 PM
  2. An array of macro functions?
    By someprogr in forum C Programming
    Replies: 6
    Last Post: 01-28-2009, 07: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, 01:27 PM