Function Parameters: pass-by-reference

Started by chassan, April 16, 2010, 09:26:40 PM

Previous topic - Next topic

chassan

Hello folks,

With Pelles C, the following function declaration gets a compiler error:
int swap(int &intA, int &intB);

However, an application with the same function in MS Visual Studio compiles and runs as expected.

I realize this can (and probably should) be done using pointers, but doesn't ANSI C allow function parameters to be declared as by-reference using something like this?  int &intA

Thanks for any help!
Chris


Stefan Pendl

The declaration is int swap(int *intA, int *intB);, but you call it value = swap(&intA, &intB);.
---
Stefan

Proud member of the UltraDefrag Development Team

AlexN

Quote from: chassan on April 16, 2010, 09:26:40 PM
int swap(int &intA, int &intB);

This is a declaration for C++, perhaps Visual Studio can compile it C-mode. Pelles C has a pure C compiler, so it does not understand it.
best regards
Alex ;)