Pergunta

In the following sample code, why sample_breaks fails to compile?

#define ONE_FRAME_OF_30FPS_2 = 1.0/30.0;

void sample_works() {
    double partOfSecondAVFoundationNumber = 2 * 1.0/30.0;
}

void sample_breaks() {
    double partOfSecondAVFoundationNumber = 2 * ONE_FRAME_OF_30FPS_2;
}
Foi útil?

Solução

It becomes this:

void sample_breaks() {
    double partOfSecondAVFoundationNumber = 2 * = 1.0/30.0;;
}

after preprocessing. So you would expect an error.

Change to

#define ONE_FRAME_OF_30FPS_2 (1.0/30.0)

instead.

Outras dicas

#define ONE_FRAME_OF_30FPS_2 = 1.0/30.0;

Should be,

#define ONE_FRAME_OF_30FPS_2 1.0/30.0

Remember, after preprocessing, ONE_FRAME_OF_30FPS_2 will be replaced by 1.0/30.0. You are not assigning ONE_FRAME_OF_30FPS_2.

Its because your macro is wrong. It should be:

#define ONE_FRAME_OF_30FPS_2 1.0/30.0
Licenciado em: CC-BY-SA com atribuição
Não afiliado a StackOverflow
scroll top