Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Error while compiling "error: unknown type name ‘Block’" #32

Closed
sdsaati opened this issue Aug 26, 2020 · 7 comments · Fixed by #41
Closed

Error while compiling "error: unknown type name ‘Block’" #32

sdsaati opened this issue Aug 26, 2020 · 7 comments · Fixed by #41

Comments

@sdsaati
Copy link

sdsaati commented Aug 26, 2020

When I want to compile it (in kubuntu 20.04) with this command: cc -lX11 blocks.h dwmblocks.c -o dwmblocks
it says:

cc -lX11 blocks.h dwmblocks.c -o dwmblocks 
blocks.h:2:14: error: unknown type name ‘Block’
    2 | static const Block blocks[] = {
      |              ^~~~~
blocks.h:4:2: warning: braces around scalar initializer
    4 |  {"Mem:", "free -h | awk '/^Mem/ { print $3\"/\"$2 }' | sed s/i//g", 30,  0},
      |  ^
blocks.h:4:2: note: (near initialization for ‘blocks[0]’)
blocks.h:4:3: warning: initialization of ‘int’ from ‘char *’ makes integer from pointer without a cast [-Wint-conversion]
    4 |  {"Mem:", "free -h | awk '/^Mem/ { print $3\"/\"$2 }' | sed s/i//g", 30,  0},
      |   ^~~~~~
blocks.h:4:3: note: (near initialization for ‘blocks[0]’)
blocks.h:4:3: error: initializer element is not computable at load time
blocks.h:4:3: note: (near initialization for ‘blocks[0]’)
blocks.h:4:11: warning: excess elements in scalar initializer
    4 |  {"Mem:", "free -h | awk '/^Mem/ { print $3\"/\"$2 }' | sed s/i//g", 30,  0},
      |           ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
blocks.h:4:11: note: (near initialization for ‘blocks[0]’)
blocks.h:4:70: warning: excess elements in scalar initializer
    4 |  {"Mem:", "free -h | awk '/^Mem/ { print $3\"/\"$2 }' | sed s/i//g", 30,  0},
      |                                                                      ^~
blocks.h:4:70: note: (near initialization for ‘blocks[0]’)
blocks.h:4:75: warning: excess elements in scalar initializer
    4 |  {"Mem:", "free -h | awk '/^Mem/ { print $3\"/\"$2 }' | sed s/i//g", 30,  0},
      |                                                                           ^
blocks.h:4:75: note: (near initialization for ‘blocks[0]’)
blocks.h:6:2: warning: braces around scalar initializer
    6 |  {"", "date '+%b %d (%a) %I:%M%p'",     5,  0},
      |  ^
blocks.h:6:2: note: (near initialization for ‘blocks[1]’)
blocks.h:6:3: warning: initialization of ‘int’ from ‘char *’ makes integer from pointer without a cast [-Wint-conversion]
    6 |  {"", "date '+%b %d (%a) %I:%M%p'",     5,  0},
      |   ^~
blocks.h:6:3: note: (near initialization for ‘blocks[1]’)
blocks.h:6:3: error: initializer element is not computable at load time
blocks.h:6:3: note: (near initialization for ‘blocks[1]’)
blocks.h:6:7: warning: excess elements in scalar initializer
    6 |  {"", "date '+%b %d (%a) %I:%M%p'",     5,  0},
      |       ^~~~~~~~~~~~~~~~~~~~~~~~~~~~
blocks.h:6:7: note: (near initialization for ‘blocks[1]’)
blocks.h:6:41: warning: excess elements in scalar initializer
    6 |  {"", "date '+%b %d (%a) %I:%M%p'",     5,  0},
      |                                         ^
blocks.h:6:41: note: (near initialization for ‘blocks[1]’)
blocks.h:6:45: warning: excess elements in scalar initializer
    6 |  {"", "date '+%b %d (%a) %I:%M%p'",     5,  0},
      |                                             ^
blocks.h:6:45: note: (near initialization for ‘blocks[1]’)
@torrinfail
Copy link
Owner

You don't want to have blocks.h in the cc command. Because blocks.h is included in dwmblocks.c it automatically gets compiled in properly. This matters because the Block typedef is in dwmblocks.c so the compiler needs to read that part first. Really you should just run 'make' to compile it but if for some reason you can't do that you can just run the CC without blocks.h

@sdsaati
Copy link
Author

sdsaati commented Sep 5, 2020

Hi, thank you for response.
it now get me this errors:

/usr/bin/ld: /tmp/ccLWzPGd.o: in function `setroot':
dwmblocks.c:(.text+0x3eb): undefined reference to `XOpenDisplay'
/usr/bin/ld: dwmblocks.c:(.text+0x45d): undefined reference to `XStoreName'
/usr/bin/ld: dwmblocks.c:(.text+0x46c): undefined reference to `XCloseDisplay'
collect2: error: ld returned 1 exit status

@torrinfail
Copy link
Owner

Are you using make to build? If not why? It should just work as long as you have libX11 and pkg-config installed.

@sdsaati
Copy link
Author

sdsaati commented Sep 6, 2020

Yes I'm using make, I have libX11 devel package, and also I have pkg-config, but don't know why I can't compile it, it's weird, maybe it needs some dependencies that I don't have.

@jasonstone20
Copy link

I have the exact same issue, running Mint 19.3

@victor-timofei
Copy link
Contributor

@jasonstone20 @satsaeid you can check out my fix of this issue here.

@torrinfail I can make a PR if you want.

@torrinfail
Copy link
Owner

Go for it.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants