質問

Porting some legacy C code from QNX (Photon C compiler) to Linux (GCC). In several places I see code like this:

void process_data(char key, char *data)
{
    int i;

    /* Required for compilation */
    i=i;
    key=key;
    data=data;

    ...
}

Obviously this code is NOT required for compilation and it does nothing.

My question is why would you ever do this in the first place?

役に立ちましたか?

解決

This removes compilation warnings/errors about unreferenced variables. Usually such stuff is done either by #pragmas or by a more expressive form, such as macro: #define unused_var(x) (x)=(x)

ライセンス: CC-BY-SA帰属
所属していません StackOverflow
scroll top