Re: More function names, same implementation



InuY4sha <inuy4sha@xxxxxxxxx> writes:
I need - if exists - the correct syntax to do something like this:

int foo1(void *)
int foo2(void *)
{
return 0;
}

Is there a way besides #defining?

Just to be clear, you want foo1 and foo2 to be two different names for
the same function, right?

In your example, ignoring the first line, you have a definition for
foo2 with no name for the parameter, which means the parameter can't
be used. I'll assume you left the name out for the sake of the
example.

int foo1(void *param)
{
return 0;
}

int (*const foo2)(void*) = foo1;

--
Keith Thompson (The_Other_Keith) kst-u@xxxxxxx <http://www.ghoti.net/~kst>
Nokia
"We must do something. This is something. Therefore, we must do this."
-- Antony Jay and Jonathan Lynn, "Yes Minister"
.



Relevant Pages

  • Evaluation order of assignment statement
    ... int array; ... Microsoft Visual C prints: foo2, foo3, foo1. ...
    (comp.lang.c)
  • Re: static final int, but constructor with (final int) arguments
    ... defining some variable as final when you are sure that its value won't ... final static variable which would be defined using a constructor, ... public Foo(final int a, final int b) { ... When you assign it from an instance, you are assigning it waaaaay too late and furthermore, it could be more than once. ...
    (comp.lang.java.help)
  • Emitting entire class from source
    ... all examples online deal only with defining a class through reflection ... someTest{public int test ... emitting a class which I could use through reflection. ...
    (microsoft.public.dotnet.framework)
  • Re: A question about One Definition Rule
    ... >> I just realized I might have broken the rule by defining the exception ... >> classes in the header file. ... Or do you mean a class declaration, ... I'm aware that a declaration can also be a definiton (as in int x; ...
    (comp.lang.cpp)
  • Re: Portable replacement
    ... int greater_or_equal4 ... On my platform, foo1 and foo2 are equivalent. ...
    (comp.lang.c)