Skip to main content
Arduino

Return to Answer

replaced http://stackoverflow.com/ with https://stackoverflow.com/
Source Link

'static' just avoids reinitialization and is used for local vars in timed interrupts for example.

volatile is another keyword you should not be using without thinking about it and does not appear to be useful for your case. See http://stackoverflow.com/questions/4592762/difference-between-const-const-volatile https://stackoverflow.com/questions/4592762/difference-between-const-const-volatile for more information

The appropiate keyword would be const, which tells the compiler this var mustn't be changed.

But I suspect there is another problem with your code, which will make the compiler throw an error as soon as you use const in the declaration. I assume you are not using the variable correctly. You are meant to use a bitwise OR | in order to set the required bit along your actual data.

So do it like this:

data_byte |= bitmasking;
write8(data_byte);

'static' just avoids reinitialization and is used for local vars in timed interrupts for example.

volatile is another keyword you should not be using without thinking about it and does not appear to be useful for your case. See http://stackoverflow.com/questions/4592762/difference-between-const-const-volatile for more information

The appropiate keyword would be const, which tells the compiler this var mustn't be changed.

But I suspect there is another problem with your code, which will make the compiler throw an error as soon as you use const in the declaration. I assume you are not using the variable correctly. You are meant to use a bitwise OR | in order to set the required bit along your actual data.

So do it like this:

data_byte |= bitmasking;
write8(data_byte);

'static' just avoids reinitialization and is used for local vars in timed interrupts for example.

volatile is another keyword you should not be using without thinking about it and does not appear to be useful for your case. See https://stackoverflow.com/questions/4592762/difference-between-const-const-volatile for more information

The appropiate keyword would be const, which tells the compiler this var mustn't be changed.

But I suspect there is another problem with your code, which will make the compiler throw an error as soon as you use const in the declaration. I assume you are not using the variable correctly. You are meant to use a bitwise OR | in order to set the required bit along your actual data.

So do it like this:

data_byte |= bitmasking;
write8(data_byte);
Source Link
mystery
  • 331
  • 1
  • 8

'static' just avoids reinitialization and is used for local vars in timed interrupts for example.

volatile is another keyword you should not be using without thinking about it and does not appear to be useful for your case. See http://stackoverflow.com/questions/4592762/difference-between-const-const-volatile for more information

The appropiate keyword would be const, which tells the compiler this var mustn't be changed.

But I suspect there is another problem with your code, which will make the compiler throw an error as soon as you use const in the declaration. I assume you are not using the variable correctly. You are meant to use a bitwise OR | in order to set the required bit along your actual data.

So do it like this:

data_byte |= bitmasking;
write8(data_byte);
lang-c

AltStyle によって変換されたページ (->オリジナル) /