Re: Optimization bug in VC++ 6.0

From: David Lowndes (davidl_at_example.invalid)
Date: 03/23/04


Date: Tue, 23 Mar 2004 17:55:04 +0000


>The following code fails to compile and cl (VC++ 6.0 SP5) returns an internal
>error.

What's the critical line of code supposed to be doing?

  tab[i] = (void *) f;

Is the "tab" array meant to be an array of function pointers, or do
you intend to call f() and store a returned pointer in the array? I
presume the intention is the latter, in which case, the following
might be what you need:

extern void * f();

void *tab[40];
void tab_init () {
 long i;
 for (i = 8; i < 11; i++) {
  tab[i] = f();
 }
}

Dave

-- 
MVP VC++ FAQ: http://www.mvps.org/vcfaq


Relevant Pages

  • Re: [PATCH 0/5] partitions: Changes to fs/partitions for readability and efficiency
    ... I'm also unconvinced that an array of function pointers is any harder to ... if (err) ... More majordomo info at http://vger.kernel.org/majordomo-info.html ...
    (Linux-Kernel)
  • Re: Is it possible to make void * safer?
    ... that's one big hit when simulating templates over using C++ templates. ... Unless you run it through a C++ compiler, ... That's why I added the function pointers, ... array_push(array, data);} ...
    (comp.lang.c)
  • Re: debugging - help
    ... i am executing on Armulator using AXD debugger. ... What i have is an array of function pointers which get periodically ... I parse this array each time, calling the functions ...
    (comp.lang.c)
  • Re: Optimizing a switch statement
    ... >>A half decent compiler will most likely implement the case statement using ... using a table of function pointers may ... > function pointer array code now gets really interesting... ... table is a better solution than a switch statement, ...
    (comp.lang.c)
  • Re: How do I call a function that has name stored in a character
    ... a binary search plus an array of function pointers will certainly be an ... One small problem with the bsearch() approach is, ... necessary to convert that to an index into an array. ...
    (alt.comp.lang.learn.c-cpp)