简体   繁体   中英

Passing constants in header function declaration

I've inherited about 1000 files that were written in C++ which I had to grudgingly convert to C. In one of the header files, a function is declared as

errnum DSPAPI aaCxSVD(complexnum *input_matrix,[...],intnum jobz=0);

which yields the following compilation error in XCode:

error: expected ';', ',' or ')' before '=' token

if I simply do intnum 0 , I get:

error: expected ';', ',' or ')' before numeric constant

if I remove intnum, I get:

error: expected declaration specifiers or '...' before numeric constant

In the C file itself, different results get returned if jobz = 0 or not. Currently, it's the only header that ever mentions that function.

My question is thus: is there any legal way of doing this? is it even necessary?

jobz has been given a default value . This is a C++-only feature.

I would say that the easiest way to convert this is simply to remove the =0 . Then, find all locations where aaCxSVD() is being called without providing an explicit final parameter, and tack on 0 .

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM