Reputation: 1371
I downloaded the source code and wanted to compile the file of scanner. It produces this error:
[meepo@localhost cs143-pp1]$ gcc -o lex.yy.o lex.yy.c -ll
In file included from scanner.l:15:0:
scanner.h:59:5: error: unknown type name ‘bool’
In file included from scanner.l:16:0:
utility.h:64:38: error: unknown type name ‘bool’
utility.h:74:1: error: unknown type name ‘bool’
In file included from scanner.l:17:0:
errors.h:16:18: fatal error: string: No such file or directory
compilation terminated.
And I tried to use different complier to compile it, but it appeared different errors.
[meepo@localhost cs143-pp1]$ g++ -o scan lex.yy.c -ll
/usr/bin/ld: cannot find -ll
collect2: ld returned 1 exit status
My os is 3.0-ARCH, I don't know why this happened. How do I fix the error?
Upvotes: 135
Views: 324691
Reputation: 191
In my case the #include <stdbool.h>
was not enough.
The solution was to set Intelli Sense Mode
to gcc-x64
in the C/C++ Extension Settings.
Upvotes: 0
Reputation: 899
C99 does, if you have
#include <stdbool.h>
If the compiler does not support C99, you can define it yourself:
// file : myboolean.h
#ifndef MYBOOLEAN_H
#define MYBOOLEAN_H
#define false 0
#define true 1
typedef int bool; // or #define bool int
#endif
(but note that this definition changes ABI for bool
type so linking against external libraries which were compiled with properly defined bool
may cause hard-to-diagnose runtime errors).
Upvotes: 70
Reputation: 5761
C90 does not support the boolean data type.
C99 does include it with this include:
#include <stdbool.h>
Upvotes: 245
Reputation: 2745
Just add the following:
#define __USE_C99_MATH
#include <stdbool.h>
Upvotes: 6
Reputation: 41617
Somewhere in your code there is a line #include <string>
. This by itself tells you that the program is written in C++. So using g++
is better than gcc
.
For the missing library: you should look around in the file system if you can find a file called libl.so
. Use the locate
command, try /usr/lib
, /usr/local/lib
, /opt/flex/lib
, or use the brute-force find / | grep /libl
.
Once you have found the file, you have to add the directory to the compiler command line, for example:
g++ -o scan lex.yy.c -L/opt/flex/lib -ll
Upvotes: 5