Error

Hello,

Getting error when trying to compile my set bits program:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32

#include <stdio.h>

#define mask (1<<n) - 1
#define mask2 ((1<<n) - 1) << p



unsigned setbits (unsigned x, int p, int n, unsigned y);
 

 
 
 int main()
	 
 {
 
    printf("%u\n", setbits(30, 2, 6, 100) );
    return 0;
    
 }
 
 unsigned setbits (unsigned x, int p, int n, unsigned y)
 
 {
 
    x = (x & ~ mask2) | (y<<n) & mask);
    return x;
    
 }




GCC: error: expected ‘;’ before ‘)’ token
error: expected statement before ‘)’ token
Last edited on
The problem is an incorrect amount of brackets on line 27
Line 27: You have unbalanced parenthesis.
Topic archived. No new replies allowed.