Thread: Problem with function's pointer!

  1. #1
    Registered User
    Join Date
    Nov 2008
    Posts
    8

    Problem with function's pointer!

    I'm embedded C programmer, a new one, and my SW arch. gave me a problem. I should call a function, throw a pointer, from address that is already given in the header of the problem, in the ROM without defining the function's pointer type. Does somebody knows about this. Any idea is worthfull!

  2. #2
    Registered User
    Join Date
    Oct 2008
    Location
    TX
    Posts
    2,059
    I'm unsure what you are after. Calling the function in your code by using a pointer to the function or declaring its prototype or maybe none of the above. Could you shed more light on the problem.
    Last edited by itCbitC; 11-28-2008 at 02:30 AM.

  3. #3
    Registered User
    Join Date
    Nov 2008
    Posts
    8
    I have a code of function on specific address in the rom. So, I have to call that function, get the back result of that function and print it....

  4. #4
    Registered User
    Join Date
    Oct 2008
    Location
    TX
    Posts
    2,059
    Do you just need to know how to declare a pointer to a function as in
    Code:
    (int) (*pfi) (int, char *); /* pfi is a pointer to a function that takes two arguments and returns an int */

  5. #5
    C++まいる!Cをこわせ!
    Join Date
    Oct 2007
    Location
    Inside my computer
    Posts
    24,654
    Easy enough.
    Code:
    typedef int /* return type */ (myfncptr_t /* name */)(/* parameter list*/int x);
    myfncptr_t* p = (myfncptr*)address;
    int x = p(1000);
    Quote Originally Posted by Adak View Post
    io.h certainly IS included in some modern compilers. It is no longer part of the standard for C, but it is nevertheless, included in the very latest Pelles C versions.
    Quote Originally Posted by Salem View Post
    You mean it's included as a crutch to help ancient programmers limp along without them having to relearn too much.

    Outside of your DOS world, your header file is meaningless.

  6. #6
    Registered User
    Join Date
    Nov 2008
    Posts
    8
    Thanks.... I got the point!

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Ban pointers or references on classes?
    By Elysia in forum C++ Programming
    Replies: 89
    Last Post: 10-30-2007, 03:20 AM
  2. A question related to strcmp
    By meili100 in forum C++ Programming
    Replies: 6
    Last Post: 07-07-2007, 02:51 PM
  3. Direct3D problem
    By cboard_member in forum Game Programming
    Replies: 10
    Last Post: 04-09-2006, 03:36 AM
  4. Could somebody please help me with this C program
    By brett73 in forum C Programming
    Replies: 6
    Last Post: 11-25-2004, 02:19 AM
  5. Quick question about SIGSEGV
    By Cikotic in forum C Programming
    Replies: 30
    Last Post: 07-01-2004, 07:48 PM