pointer to a function

This is a discussion on pointer to a function within the C Programming forums, part of the General Programming Boards category; Hi I have a pointer to a function, like this: Code: extern MyProces(); void(*ProcesPtr)(void) = MyProces; How do I place ...

  1. #1
    Registered User
    Join Date
    Dec 2005
    Location
    Denmark
    Posts
    13

    pointer to a function

    Hi

    I have a pointer to a function, like this:
    Code:
    extern MyProces();
    
    void(*ProcesPtr)(void) = MyProces;
    How do I place the pointer in the rom insted of the ram.

  2. #2
    cwr
    cwr is offline
    Registered Luser cwr's Avatar
    Join Date
    Jul 2005
    Location
    Sydney, Australia
    Posts
    868
    Platform? Operating system (if any)? Could you be any less vague?

  3. #3
    and the hat of wrongness Salem's Avatar
    Join Date
    Aug 2001
    Location
    The edge of the known universe
    Posts
    32,417
    > How do I place the pointer in the rom insted of the ram.
    Well you could try making it const, but then the function name is also const as well so what's the point?

  4. #4
    Registered User
    Join Date
    Dec 2005
    Location
    Denmark
    Posts
    13
    non Operating system.

    Well you could try making it const, but then the function name is also const as well so what's the point?
    I have some structís with data.

    I donít want to use the same function, for all of my structís, for this reason I want the pointer, then I will include the pointer I my structís.

  5. #5
    Sr. Software Engineer filker0's Avatar
    Join Date
    Sep 2005
    Location
    West Virginia
    Posts
    235
    Quote Originally Posted by ramdal
    non Operating system.
    By this, do you mean that this is an embedded application? How do you put your struct into ROM? If your function pointer is a struct member, then you simply use a static initializer for the struct and use the same tools that you use for putting structs into a ROM section. If this is not what you're doing, or if you need to make it so that you can change which function is being pointed to by the pointer at run-time, you're a bit out of luck other than using a pointer to a pointer to a function, and have a RAM resident function pointer that is pointed to by the ROM resident pointer. I've done both in the past.
    Insert obnoxious but pithy remark here

  6. #6
    Registered User
    Join Date
    Dec 2005
    Location
    Denmark
    Posts
    13
    Yes ok, I think I got it, thanks.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. sorting number
    By Leslie in forum C Programming
    Replies: 8
    Last Post: 05-20-2009, 04:23 AM
  2. <Gulp>
    By kryptkat in forum Windows Programming
    Replies: 7
    Last Post: 01-14-2006, 12:03 PM
  3. Function Pointer help
    By Skydt in forum C Programming
    Replies: 5
    Last Post: 12-02-2005, 08:13 AM
  4. pointers
    By InvariantLoop in forum C Programming
    Replies: 13
    Last Post: 02-04-2005, 08:32 AM
  5. Interface Question
    By smog890 in forum C Programming
    Replies: 11
    Last Post: 06-03-2002, 05:06 PM

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