I met some compilation error but do not know what the problem is. The code seems not use exception, but the error is about it.
//in misc.h:
char *basename(char *name); // line 94
// in misc.cc:
char *basename(char *name) { // line 12
char *result = name;
while(*name) {
if(*name == '/') result = name + 1;
name++;
}
return result;
}
Compilation error
g++ -pipe -W -Wall -fopenmp -ggdb3 -O2 -c -o misc.o ../../src/misc.cc
../../src/misc.cc: In function ‘char* basename(char*)’:
../../src/misc.cc:12: error: declaration of ‘char* basename(char*)’ throws different exceptions
../../src/misc.h:94: error: from previous declaration ‘char* basename(char*) throw ()’
make: *** [misc.o] Error 1
Does someone have some clue? Thanks and regards!
EDIT:
Files included in misc.h are
#include <iostream>
#include <cmath>
#include <fstream>
#include <cfloat>
#include <stdlib.h>
#include <string.h>
EDIT:
in misc.i generated by -E option,
extern "C++" char *basename (char *__filename)
throw () __asm ("basename") __attribute__ ((__nonnull__ (1)));
extern "C++" __const char *basename (__const char *__filename)
throw () __asm ("basename") __attribute__ ((__nonnull__ (1)));
# 640 "/usr/include/string.h" 3 4
# 1 "/usr/include/bits/string3.h" 1 3 4
# 23 "/usr/include/bits/string3.h" 3 4
extern void __warn_memset_zero_len (void) __attribute__((__warning__ ("memset used with constant zero length parameter; this could be due to transposed parameters")));
# 48 "/usr/include/bits/string3.h" 3 4
extern __inline __attribute__ ((__always_inline__)) __attribute__ ((__gnu_inline__, __artificial__)) void *
memcpy (void *__restrict __dest, __const void *__restrict __src, size_t __len) throw ()
{
return __builtin___memcpy_chk (__dest, __src, __len, __builtin_object_size (__dest, 0));
}
...
# 641 "/usr/include/string.h" 2 3 4
...
You may be picking up the definition of basename() from libgen.h. On my OpenSUSE system, the version in libgen.h is defined with "throw ()" at the end (via the __THROW macro).
One thing you can try is to tell gcc to only run the preprocessor stage by adding the -E flag and then search for basename to see what is being defined:
g++ -pipe -W -Wall -fopenmp -ggdb3 -O2 -E -o misc.i ../../src/misc.cc
If that is happening, you'll either need to drop the include of libgen.h, match the throw specifier or change the name of your function.
" ../../src/misc.h:94: error: from previous declaration ‘char* basename(char*) throw ()’ "
I'm reading that as having been declared twice, once with throw() and once without.
Compiles for me, same flags.
g++ (Gentoo 4.3.4 p1.0, pie-10.1.5) 4.3.4
Your error says that there is a declaration of ‘char* basename(char*) throw ()’
try opening misc.h and searching for throw in the entire file, to see if you put the throw in yourself and just forgot about it.
Related
I am not sure if I am the only person or this is the problem of so many other people.
What I suffer from is that for an even simple code that includes LLVM headers regardless of what ever I write in my main function, I get too many warnings when I compile my codes with extra warnings:
#include <llvm/IR/IRBuilder.h>
#include <llvm/IR/Verifier.h>
#include <llvm/Support/TargetSelect.h>
#include <llvm/ExecutionEngine/ExecutionEngine.h>
#include <llvm/IR/Instructions.h>
int main()
{
return 0;
}
I cat get these warnings by using either gcc or clang:
g++-9 -std=c++17 main.cpp -Wall -Wextra -I/usr/lib/llvm-9/include -c -o main.o
clang++-9 -std=c++17 main.cpp -Wall -Wextra -I/usr/lib/llvm-9/include -c -o main.o
They are mainly unused parameters:
In file included from /usr/lib/llvm-9/include/llvm/IR/ConstantFolder.h:20,
from /usr/lib/llvm-9/include/llvm/IR/IRBuilder.h:24,
from main.cpp:1:
/usr/lib/llvm-9/include/llvm/IR/Constants.h: In member function ‘llvm::Value* llvm::ConstantData::handleOperandChangeImpl(llvm::Value*, llvm::Value*)’:
/usr/lib/llvm-9/include/llvm/IR/Constants.h:60:41: warning: unused parameter ‘From’ [-Wunused-parameter]
60 | Value *handleOperandChangeImpl(Value *From, Value *To) {
| ~~~~~~~^~~~
/usr/lib/llvm-9/include/llvm/IR/Constants.h:60:54: warning: unused parameter ‘To’ [-Wunused-parameter]
60 | Value *handleOperandChangeImpl(Value *From, Value *To) {
| ~~~~~~~^~
In file included from /usr/lib/llvm-9/include/llvm/IR/ConstantFolder.h:21,
from /usr/lib/llvm-9/include/llvm/IR/IRBuilder.h:24,
from main.cpp:1:
/usr/lib/llvm-9/include/llvm/IR/InstrTypes.h: In member function ‘bool llvm::CallBase::isFnAttrDisallowedByOpBundle(llvm::StringRef) const’:
/usr/lib/llvm-9/include/llvm/IR/InstrTypes.h:1913:47: warning: unused parameter ‘S’ [-Wunused-parameter]
1913 | bool isFnAttrDisallowedByOpBundle(StringRef S) const {
| ~~~~~~~~~~^
In file included from /usr/lib/llvm-9/include/llvm/IR/IRBuilder.h:33,
from main.cpp:1:
/usr/lib/llvm-9/include/llvm/IR/Instructions.h: In member function ‘llvm::BasicBlock* llvm::ReturnInst::getSuccessor(unsigned int) const’:
/usr/lib/llvm-9/include/llvm/IR/Instructions.h:2943:37: warning: unused parameter ‘idx’ [-Wunused-parameter]
2943 | BasicBlock *getSuccessor(unsigned idx) const {
| ~~~~~~~~~^~~
...
I just truncate these warnings. They are too many.
When I turn on the -Wconversion the problem becomes even worse:
In file included from /usr/lib/llvm-9/include/llvm/Support/MathExtras.h:17,
from /usr/lib/llvm-9/include/llvm/ADT/SmallVector.h:19,
from /usr/lib/llvm-9/include/llvm/ADT/STLExtras.h:20,
from /usr/lib/llvm-9/include/llvm/ADT/StringRef.h:12,
from /usr/lib/llvm-9/include/llvm/ADT/StringMap.h:16,
from /usr/lib/llvm-9/include/llvm/Support/Host.h:16,
from /usr/lib/llvm-9/include/llvm/ADT/Hashing.h:48,
from /usr/lib/llvm-9/include/llvm/ADT/ArrayRef.h:12,
from /usr/lib/llvm-9/include/llvm/IR/IRBuilder.h:18,
from main.cpp:1:
/usr/lib/llvm-9/include/llvm/Support/SwapByteOrder.h: In function ‘uint16_t llvm::sys::SwapByteOrder_16(uint16_t)’:
/usr/lib/llvm-9/include/llvm/Support/SwapByteOrder.h:36:23: warning: conversion from ‘int’ to ‘uint16_t’ {aka ‘short unsigned int’} may change value [-Wconversion]
36 | uint16_t Hi = value << 8;
| ~~~~~~^~~~
/usr/lib/llvm-9/include/llvm/Support/SwapByteOrder.h:37:23: warning: conversion from ‘int’ to ‘uint16_t’ {aka ‘short unsigned int’} may change value [-Wconversion]
37 | uint16_t Lo = value >> 8;
| ~~~~~~^~~~
In file included from /usr/lib/llvm-9/include/llvm/ADT/STLExtras.h:20,
from /usr/lib/llvm-9/include/llvm/ADT/StringRef.h:12,
from /usr/lib/llvm-9/include/llvm/ADT/StringMap.h:16,
from /usr/lib/llvm-9/include/llvm/Support/Host.h:16,
from /usr/lib/llvm-9/include/llvm/ADT/Hashing.h:48,
from /usr/lib/llvm-9/include/llvm/ADT/ArrayRef.h:12,
from /usr/lib/llvm-9/include/llvm/IR/IRBuilder.h:18,
from main.cpp:1:
/usr/lib/llvm-9/include/llvm/ADT/SmallVector.h: In constructor ‘llvm::SmallVectorBase::SmallVectorBase(void*, size_t)’:
/usr/lib/llvm-9/include/llvm/ADT/SmallVector.h:45:35: warning: conversion from ‘size_t’ {aka ‘long unsigned int’} to ‘unsigned int’ may change value [-Wconversion]
45 | : BeginX(FirstEl), Capacity(TotalCapacity) {}
| ^~~~~~~~~~~~~
...
I get these warnings by clang too:
...
In file included from main.cpp:1:
In file included from /usr/lib/llvm-9/include/llvm/IR/IRBuilder.h:18:
In file included from /usr/lib/llvm-9/include/llvm/ADT/ArrayRef.h:12:
/usr/lib/llvm-9/include/llvm/ADT/Hashing.h:190:15: warning: implicit conversion changes signedness: 'const char' to 'uint8_t' (aka 'unsigned char') [-Wsign-conversion]
uint8_t a = s[0];
~ ^~~~
/usr/lib/llvm-9/include/llvm/ADT/Hashing.h:191:15: warning: implicit conversion changes signedness: 'const char' to 'uint8_t' (aka 'unsigned char') [-Wsign-conversion]
uint8_t b = s[len >> 1];
~ ^~~~~~~~~~~
/usr/lib/llvm-9/include/llvm/ADT/Hashing.h:192:15: warning: implicit conversion changes signedness: 'const char' to 'uint8_t' (aka 'unsigned char') [-Wsign-conversion]
uint8_t c = s[len - 1];
~ ^~~~~~~~~~
...
This is just a MWE. Adding more headers, I can get other types of warnings such as
/usr/lib/llvm-9/include/llvm/ADT/Twine.h:232:16: warning: ‘<anonymous>.llvm::Twine::RHS.llvm::Twine::Child::twine’ may be used uninitialized in this function [-Wmaybe-uninitialized]
!RHS.twine->isBinary())
~~~~^~~~~
Now, I am wondering whether LLVM is written carelessly? I always turn on all warnings and make sure my application compiles with 0 warnings. When I do this while using LLVM all warnings of my code are burried under LLVM ones. I cannot easily see them. Usually the first advise from people is to turn off those warnings switches. I strictly resist that. I want to find them for my application. The alternative solution comes to my mind is to turn off these warnings only for LLVM but not for my application. Is this possible especially when using CMake?
The issue of system header files causing warnings is a common one. It is not really for me to judge whether the authors of those headers were "careless" or not, but there is a relatively simple way to disable specific warnings before including the 'offending' headers, then restore your 'full' warnings once they have been included.
For clang you can do this with various #pragma diagnostic ... lines, as shown in the following code snippet:
#if defined (__clang__)
#pragma clang diagnostic push // Saves current diagnostic settings
#pragma clang diagnostic ignored "-Wsign-conversion" // Ignore this warning
#pragma clang diagnostic ignored "-Wunused-parameter" // and this one...
// ... Add similar lines for other warnings you wish to disable
#endif
// Now include the 'offending' headers ...
#include <llvm/IR/IRBuilder.h>
#include <llvm/IR/Verifier.h>
#include <llvm/Support/TargetSelect.h>
#include <llvm/ExecutionEngine/ExecutionEngine.h>
#include <llvm/IR/Instructions.h>
#if defined(__clang__)
#pragma clang diagnostic pop // Restores the saved settings
#endif
I don't have access to a GCC compiler but I believe very similar directives can be used: just substitute GCC for clang in the lines where that occurs. More information on such #pragma directives (for the GCC versions) can be found here.
It is dependent on your GCC/clang/OS installation. On Fedora 32 it works as expected out of the box with system gcc-10.2.1-1.fc32.x86_64 + system clang-10.0.0-2.fc32.x86_64:
#include <llvm/IR/IRBuilder.h>
#include <llvm/IR/Verifier.h>
#include <llvm/Support/TargetSelect.h>
#include <llvm/ExecutionEngine/ExecutionEngine.h>
#include <llvm/IR/Instructions.h>
static void func(int val) {}
int main()
{
func(42);
return 0;
}
For GCC:
$ g++ -o stackoverflowllvmwarnings stackoverflowllvmwarnings.C $(llvm-config --cflags --libs) -std=c++17 -Wall -Wextra
stackoverflowllvmwarnings.C: In function ‘void func(int)’:
stackoverflowllvmwarnings.C:7:22: warning: unused parameter ‘val’ [-Wunused-parameter]
7 | static void func(int val) {}
| ~~~~^~~
$ _
For clang:
$ clang++ -o stackoverflowllvmwarnings stackoverflowllvmwarnings.C $(llvm-config --cflags --libs) -std=c++17 -Wall -Wextra
stackoverflowllvmwarnings.C:7:22: warning: unused parameter 'val' [-Wunused-parameter]
static void func(int val) {}
^
1 warning generated.
$ _
If you really want (you do not) the warnings even for system headers use Wsystem-headers (it works similar way both for gcc and clang):
$ clang++ -o stackoverflowllvmwarnings stackoverflowllvmwarnings.C $(llvm-config --cflags --libs) -std=c++17 -Wall -Wextra -Wsystem-headers
In file included from stackoverflowllvmwarnings.C:1:
In file included from /usr/include/llvm/IR/IRBuilder.h:17:
In file included from /usr/include/llvm-c/Types.h:17:
In file included from /usr/include/llvm-c/DataTypes.h:28:
In file included from /usr/bin/../lib/gcc/x86_64-redhat-linux/10/../../../../include/c++/10/cmath:42:
/usr/bin/../lib/gcc/x86_64-redhat-linux/10/../../../../include/c++/10/bits/cpp_type_traits.h:110:12: warning: keyword '__is_void' will be made available as an identifier for the remainder of the translation unit [-Wkeyword-compat]
struct __is_void
^
...
When compiling I am getting the same warning on 3 different lines of code in a .h file such as this:
warning gnu_printf is an unrecognized format function type
My flags look like this:
CFLAGS += -Wall -Wextra -Wformat -Wno-ignored-qualifiers -Wformat-security -Wno-unused-parameter \
Examples of the three lines of code producing this error below:
int ATTR_WARN_PRINTF(1,2) OutputDebugStringF(const char* pszFormat, ...);
std::string ATTR_WARN_PRINTF(1,3) real_strprintf(const char *format, int dummy, ...);
bool ATTR_WARN_PRINTF(1,2) error(const char *format, ...);
I have many other uses of printf() in this file that are not producing any errors. I am a bit confused on the error in the formatting.
Apparently the failing code is:
#ifdef __GNUC__
#define ATTR_WARN_PRINTF(X,Y) __attribute__((format(gnu_printf,X,Y)))
#else
#define ATTR_WARN_PRINTF(X,Y)
#endif
int ATTR_WARN_PRINTF(1,2) OutputDebugStringF(const char* pszFormat, ...);
std::string ATTR_WARN_PRINTF(1,3) real_strprintf(const char *format, int dummy, ...);
bool ATTR_WARN_PRINTF(1,2) error(const char *format, ...);
It seems that this works on any gcc between versions 4.4.7 and gcc trunk (9.0.0).
GCC 4.1.2 fails with:
<source>:7: warning: 'gnu_printf' is an unrecognized format function type
Also, clang always fails on this:
<source>:7:5: warning: 'format' attribute argument not supported: gnu_printf [-Wignored-attributes]
But from the original question it seems that the issue with a GCC which is too old. To fix this, check GCC version number:
#if defined(__GNUC__) && ((__GNUC__ == 4 && __GNUC_MINOR__>= 4) || __GNUC__ > 4)
# define ATTR_WARN_PRINTF(X,Y) __attribute__((format(gnu_printf,X,Y)))
#elif defined(__GNUC__)
# define ATTR_WARN_PRINTF(X,Y) __attribute__((format(printf,X,Y)))
#else
# define ATTR_WARN_PRINTF(X,Y)
#endif
Maybe even it is better to restrict the format to printf instead of gnu_printf, and so the above condition can be simplified.
EDIT: As can be found on GCC history, the gnu_printf format was added in gcc-4.4.0
commit r133365. From what I understand, it is merely an alias to printf, and the gnu prefix was added to allow differentiation between printf of different compilers, such as possibly ms_printf.
I try to compile this C++/Python library https://bitbucket.org/fluiddyn/fluidfft
If mpi4py is installed, it works well.
If mpi4py is not installed, code that does not use MPI cannot be compiled.
An error is raise during the compilation of a Cython file. The error is long and it starts by:
In file included from /usr/include/c++/6/bits/ios_base.h:46:0,
from /usr/include/c++/6/ios:42,
from /usr/include/c++/6/ostream:38,
from /usr/include/c++/6/iostream:39,
from src_cpp/base/base_fft.h:10,
from fluidfft/fft2d/fft2d_with_fftw1d.cpp:543:
/usr/include/c++/6/system_error:143:31: error: ‘error_category’ does not name a type
error_code(int __v, const error_category& __cat) noexcept
^~~~~~~~~~~~~~
/usr/include/c++/6/system_error:152:27: error: ‘error_category’ does not name a type
assign(int __v, const error_category& __cat) noexcept
^~~~~~~~~~~~~~
/usr/include/c++/6/system_error:172:11: error: ‘error_category’ does not name a type
const error_category&
^~~~~~~~~~~~~~
/usr/include/c++/6/system_error:191:11: error: ‘error_category’ does not name a type
const error_category* _M_cat;
[...]
I guess it could be a C++11 problem (http://en.cppreference.com/w/cpp/error/error_category) but I don't see how to solve the problem.
The compilation command is
g++ -pthread -fwrapv -O3 -Wall -Wno-unused-result -Wsign-compare -Wno-unused-result -Wsign-compare -fwrapv -O3 -Wall -fPIC -I/home/users/me/opt/miniconda3/include/python3.6m -I/home/users/me/opt/miniconda3/include -Isrc_cy -Ifluidfft/fft2d -Ifluidfft/fft3d -Isrc_cpp/base -Isrc_cpp/3d -Isrc_cpp/2d -Iinclude -I/home/users/me/opt/miniconda3/lib/python3.6/site-packages/numpy/core/include -c fluidfft/fft2d/fft2d_with_fftw1d.cpp -o build/temp.linux-x86_64-3.6/fluidfft/fft2d/fft2d_with_fftw1d.o
Edit Minimal, Complete, and Verifiable example
Thanks to Ashwin Vishnu (see https://bitbucket.org/fluiddyn/fluidfft/issues/7/fluidfft-installation-fails-without-mpi4py), I can post a minimal example
/* test.cpp */
#include <Python.h>
#include <string.h>
#include <stdio.h>
#include <cpu.h>
#include <sys/time.h>
#include <complex>
#include <iostream>
int main() {
std::cout<<"Hello world";
return 0;
}
compiled from fluidfft directory as follows:
g++ $(python-config --include) -Iinclude/ test.cpp
If we comment out cpu.h include, there are no errors.
The file cpu.h was taken from the pyfftw code: https://github.com/pyFFTW/pyFFTW/blob/master/include/cpu.h
This happens because the package fluidfft's Cython source files relied on a C++ header file cpu.h wherein the following preprocessor lines caused problems:
#if __STDC_VERSION__ >= 199901L
/* "inline" is a keyword */
#else
# define inline
#endif
My guess is the newer g++ compilers are strict on redefining reserved keywords. Following hints from an essay on inline functions, this block of code was replaced with:
#if __STDC_VERSION__ >= 199901L
/* "inline" is a keyword */
#else
# define INLINE
#endif
#ifndef INLINE
# if __GNUC__ && !__GNUC_STDC_INLINE__
# define INLINE static inline
# else
# define INLINE inline
# endif
#endif
I have tried a lot, but could not figure out what the errors are.
Any detailed explanation about the this will be very helpful.
So basically i am trying to write a re-entrant parser and these are my files.
Lex1.ll
%{
#include "Globals.h"
#include "yac1.tab.hh"
extern "C"
{
int yylex(void);
}
%}
alpha [A-Za-z]
digit [0-9]
%option case-insensitive
%option bison-bridge
%option reentrant
%option noyywrap
%%
"DELETE ALL" return DELALL;
"INSERT" return INSERT;
DELETE return DELETE;
FIND return FIND;
(\+|\-)?[0-9]+ { return INT; }
\n { return ENDL; }
. ;
%%
yac1.yy
%{
#include <stdio.h>
#include "Globals.h"
%}
%pure-parser
%error-verbose
%{
#define YYPARSE_PARAM parm
#define YYLEX_PARAM ((struct parsed_vals *)parm)->scanner
#define cast ((struct parsed_vals *) parm)
void yyerror(struct parsed_vals * parm,const char *s)
{
fprintf(stderr, "error: %s\n", s);
}
extern "C"
{
int yylex(void );
// int yywrap()
// {
// return 1;
// }
}
%}
%token INSERT DELETE DELALL FIND ENDL
%union {
int ival;
float fval;
char *sval;
}
%token <ival> INT
%token <fval> FLOAT
%token <sval> STRING
%%
S:T
T: INSERT val {cast->cmd=INSERT_CMD;}
| DELETE val {cast->cmd=DELETE_CMD;}
;
val : INT ENDL {cast->type=INT_TYPE;
(cast->data).int_data=$1;}
|
FLOAT ENDL {cast->type=FLOAT_TYPE;
(cast->data).float_data=$1;}
|
STRING ENDL {cast->type=STRING_TYPE;
(cast->data).str_data=$1;}
;
%%
My main function testlex.cc
#include <stdio.h>
#include "Globals.h"
#include "lexheader.h"
#include "yac1.tab.hh"
int yyparse(void *);
yyscan_t scanner;
main()
{
struct parsed_vals foo;
const char * buffer = "inseRt 4\n";
yylex_init(&(foo.scanner));
yyset_extra(&foo, foo.scanner);
YY_BUFFER_STATE bp = yy_scan_string( buffer, foo.scanner );
yy_switch_to_buffer(bp, foo.scanner);
int a;
int ret_val = yyparse(&foo);
yy_delete_buffer(bp, foo.scanner);
if(ret_val!=0) printf("False");
printf ("hello %d\n",foo.data.int_data);
printf ("hello %d\n",foo.type);
yylex_destroy(foo.scanner);
}
Globals.h
/*
* File: Globals.h
* Author: atghosh
*
* Created on 3 August, 2013, 8:39 PM
*/
#ifndef GLOBALS_H
#define GLOBALS_H
enum CMD {INSERT_CMD=1, DELETE_CMD, FIND_CMD, DELALL_CMD};
enum TYPE {INT_TYPE=5, FLOAT_TYPE, STRING_TYPE};
struct parsed_vals{
int cmd;
int type;
union{
int int_data;
float float_data;
char *str_data;
} data;
void * scanner;
};
#endif /* GLOBALS_H */
Makefile
parser: lex1.ll yac1.yy testlex.cc
bison -d yac1.yy
flex --header-file="lexheader.h" lex1.ll
g++ -o parser yac1.tab.cc lex.yy.c testlex.cc -lfl
clean:
rm -rf *.o parser lexheader.h lex.yy.c lex.yy.cc parser yac1.tab.cc yac1.tab.hh
And my error list
bison -d yac1.yy
flex --header-file="lexheader.h" lex1.ll
g++ -o parser yac1.tab.cc lex.yy.c testlex.cc -lfl
yac1.tab.cc: In function ‘int yyparse(void*)’:
yac1.tab.cc:1302:16: error: too many arguments to function ‘int yylex()’
yac1.yy:20:13: note: declared here
yac1.tab.cc:1510:24: error: cannot convert ‘const char*’ to ‘parsed_vals*’ for argument ‘1’ to ‘void yyerror(parsed_vals*, const char*)’
yac1.tab.cc:1625:35: error: cannot convert ‘const char*’ to ‘parsed_vals*’ for argument ‘1’ to ‘void yyerror(parsed_vals*, const char*)’
In file included from testlex.cc:3:0:
lexheader.h:278:1: error: ‘YYSTYPE’ does not name a type
lexheader.h:280:18: error: variable or field ‘yyset_lval’ declared void
lexheader.h:280:18: error: ‘YYSTYPE’ was not declared in this scope
lexheader.h:280:28: error: ‘yylval_param’ was not declared in this scope
lexheader.h:280:51: error: expected primary-expression before ‘yyscanner’
lexheader.h:328:17: warning: ‘yylex’ initialized and declared ‘extern’ [enabled by default]
lexheader.h:328:17: error: ‘YYSTYPE’ was not declared in this scope
lexheader.h:328:27: error: ‘yylval_param’ was not declared in this scope
lexheader.h:328:50: error: expected primary-expression before ‘yyscanner’
lexheader.h:328:59: error: expression list treated as compound expression in initializer [-fpermissive]
make: *** [parser] Error 1
I am just not able to figure out what is going wrong.
Expecting detailed reply and no links.
I have already referred to these links
http://www.phpcompiler.org/articles/reentrantparser.html
http://plindenbaum.blogspot.in/2009/12/parsing-genetic-code-using-flex-and_14.html
Here's a number of issues and the corresponding fixes.
Erase the prototype of yylex from both lex1.ll and yac1.yy. You shouldn't have to define it yourself anywhere.
Add two #include's near the beginning of yac1.yy:
#include "yac1.tab.hh"
#include "lexheader.h"
Make sure you have them in this order, as the first one defines YYSTYPE which is used by the second one. This is a known issue with flex/bison lexers and parsers.
Fix the prototype and the definition of yyerror in yac1.yy. It should be:
void yyerror(const char *s);
If you need an extra parameter there, for your own purpose from your own calls, you
cannot expect the parser to provide it. In this case, define your own error handler
and use a different name.
After all this, your program compiles using your Makefile. Whether it works as expected or not, I cannot tell.
#include <iostream>
#include <string.h>
char* basename(const char* filname);
int main()
{
return 0;
}
char *basename(const char* filename)
{
char* base = (char *)filename;
return base ;
}
compiling on g++ 4.1.2 20070115 (SUSE 10): No issue
compiling on g++ 4.3.4 (SUSE 11) gives following error
fileName : 9 :error:declaration of char* basename(const char*) throws different exception
fileName:3:error: from previous declaration char* basename(const char*) throw () .
Kindly tell me why this is happening , Is there is any Interface changed in g++ between these two release (if I remove inclusion of string.h then compilation success on both version of g++ ,Is any Interface change in string.h).
looks like basename already defined in string.h
# ifndef basename
/* Return the file name within directory of FILENAME. We don't
declare the function if the `basename' macro is available (defined
in <libgen.h>) which makes the XPG version of this function
available. */
# ifdef __CORRECT_ISO_CPP_STRING_H_PROTO
extern "C++" char *basename (char *__filename)
__THROW __asm ("basename") __nonnull ((1));
extern "C++" __const char *basename (__const char *__filename)
__THROW __asm ("basename") __nonnull ((1));
# else
extern char *basename (__const char *__filename) __THROW __nonnull ((1));
# endif
# endif
It seems the name basename already exists in string.h:
http://ideone.com/Q9xSw - gives error (as it is exactly your code).
http://ideone.com/s0HIX compiles fine if you comment #include <string.h>