?
Solved

Alternative to function pointer?

Posted on 2010-11-09
3
Medium Priority
?
699 Views
Last Modified: 2012-05-10
Hello,

I need to define a function in one file but reference it in another. I am currently doing this by passing a function pointer. However, I can no longer use function pointers for this*, so is there an alternative way of achieving the same thing?

Thank you!

* For those interested in why: I am actually using C for CUDA, and it turns out that the architecture version one needs to compile for in order to use the 'constant memory' on GPUs does not support function pointers within GPU kernels! And since using constant memory is more important for me than using function pointers, I am forced to look for an alternative.
0
Comment
Question by:InteractiveMind
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
3 Comments
 
LVL 40

Assisted Solution

by:evilrix
evilrix earned 800 total points
ID: 34098375
You have two choices to call a function, you either call it directly or indirectly via a function pointer.
0
 
LVL 53

Accepted Solution

by:
Infinity08 earned 1200 total points
ID: 34099731
I'm a bit confused : unless the function is static (ie. local to the compilation unit), you can just call it. If it is static, then you probably shouldn't be calling it (assuming there was a good reason to make it static in the first place).

Maybe you can show some code, so we get a better idea of what you're dealing with ?
0
 
LVL 25

Author Closing Comment

by:InteractiveMind
ID: 34277450
Sorry for the delay, I've been very busy lately. I didn't realise I could just call a function in another file without first including it - so thank you!
0

Featured Post

VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Have you thought about creating an iPhone application (app), but didn't even know where to get started? Here's how: ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ Important pre-programming comments: I’ve never tri…
Preface I don't like visual development tools that are supposed to write a program for me. Even if it is Xcode and I can use Interface Builder. Yes, it is a perfect tool and has helped me a lot, mainly, in the beginning, when my programs were small…
The goal of this video is to provide viewers with basic examples to understand opening and writing to files in the C programming language.
The goal of this video is to provide viewers with basic examples to understand how to create, access, and change arrays in the C programming language.
Suggested Courses

801 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question