CW chokes when calling functions with optional arguments.

cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

CW chokes when calling functions with optional arguments.

524 Views
cktrod
Contributor I

I'm using CW 7.2 Build 91218 with the coldfire architecture.  I have a mix of C and C++ in the project and have force C++ compilation checked in the C/C++ options.

 

Whenever I call a function and I leave out arguments that are defaulted in the function declaration, the compiler throws an error because the data types of the arguments in the function call don't match the function name and parameters list in any function declaration.

 

Example:

int foo(int a, int b = 0);

 

void main(int)

{

    foo(5);   // throws an error

    foo(5,0);   // doesn't throw an error

}

 

Does anyone have any idea why this would be happening?

 

Thanks,

Rod

Labels (1)
0 Kudos
2 Replies

376 Views
CrasyCat
Specialist III

Hello

 

    What is the extension of the source file, where you place the function prototype for foo (.c or .cpp)?

    Where is the function foo implemented (in a .c or ,cpp file)?

    What error message are you getting exactly?

  

CrasyCat

0 Kudos

376 Views
cktrod
Contributor I

The function declaration was a class constructor in a .h file.  The error was flagged when an instance of the class was statically instantiated in a .cpp file.  I don't remember the exact text of the error other than it was the one you see when the data types of the arguments in a function call don't exactly match the data types of the parameters in the function declaration.

 

I tried to code a simple solution from a new project and I couldn't duplicate the compile error when calling a function with optional arguments. 

 

I saw the problem when I ported a bunch of code from another project and I had hundreds of errors to fix.  I have since fixed all of the seemingly unrelated errors and now I can't duplicate the problem.

 

I'm going to assume that this is a non-issue, until I see the error when I have no other errors in my project.

 

Thanks,

Rod

0 Kudos