Improve company productivity with a Business Account.Sign Up

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 704
  • Last Modified:

Alternative to function pointer?

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
InteractiveMind
Asked:
InteractiveMind
2 Solutions
 
evilrixSenior Software Engineer (Avast)Commented:
You have two choices to call a function, you either call it directly or indirectly via a function pointer.
0
 
Infinity08Commented:
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
 
InteractiveMindAuthor Commented:
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
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

Join & Write a Comment

Featured Post

Problems using Powershell and Active Directory?

Managing Active Directory does not always have to be complicated.  If you are spending more time trying instead of doing, then it's time to look at something else. For nearly 20 years, AD admins around the world have used one tool for day-to-day AD management: Hyena. Discover why

Tackle projects and never again get stuck behind a technical roadblock.
Join Now