So I'm about to finish my course in university in C programming. I want to get better at bit operations (such as creating masks) so I'll go to it:
#define BIT_I_SET(TYPE,I) ((TYPE)(1) << (I))
#define SET_BIT(NUM,I,TYPE) \
NUM |= BIT_I_SET(I,TYPE)
I am still at the early stages and learning the syntax at the moment, I have no idea why the compiler says there's error: Severity Code Description Project File Line Suppression State Error (active) E0109 expression preceding parentheses of apparent call must have (pointer-to-) function type Project14
full program (yeah it's for synatx only):
#include <stdio.h>
#include <stdlib.h>
#define SHIFT(I,TYPE) ((TYPE)(1) << (I))
#define NEGATIVE(TYPE) (~(TYPE)(0))
#define BIT_I_SET(TYPE,I) ((TYPE)(1) << (I))
#define BIT_I_CLEAR(I,TYPE) (~((TYPE)(1)<< (I)))
#define MSB_SET(TYPE) ((TYPE)(1) << (sizeof(TYPE)*8-1)
#define SET_BIT(NUM,I,TYPE) \
NUM |= BIT_I_SET(I,TYPE)
void main()
{
unsigned char i, j;
int shift = 3;
i = 0;
j = 0;
SET_BIT(j, 2, unsigned char);
printf("%d\n",sizeof(j));
printf("%d",i);
system("pause>null");
}