From http://cppcms.com/wikipp/en/page/cppcms_1x_forms,
According to this,
A declaration introduces one or more names into a program.....
Therefore, classes, structures, enumerated types, and other
user-defined types can be declared for each compilation unit
AFAIK, constructor should be in myapp.cpp, while declaration should be in content.h. So I put
There are 5 fields on the form. In CppCMS, the form built using 3 codes (the 4th codes are restriction for the fields)
1st codes:
name.message("Your Name");
sex.message("Sex");
marital.message("Marital Status");
age.message("Your Age");
submit.value("Send");
2nd codes:
add(name);
add(sex);
add(marital);
add(age);
add(submit);
3rd codes:
sex.add("Male","male");
sex.add("Female","female");
marital.add("Single","single");
marital.add("Married","married");
marital.add("Divorced","divorced");
4th codes, are restriction for the fields:
name.non_empty();
age.range(0,120);
I'm quite confused which one should be declaration
------------------added
I've tried add all above codes in myapp.cpp like below:
class myapp : public cppcms::application {
public:
myapp(cppcms::service &srv) : cppcms::application(srv)
{
dispatcher().assign("",&myapp::info_form,this);
mapper().assign("");
}
void info_form()
{
name.message("Your Name");
sex.message("Sex");
marital.message("Marital Status");
age.message("Your Age");
submit.value("Send");
add(name);
add(sex);
add(marital);
add(age);
add(submit);
sex.add("Male","male");
sex.add("Female","female");
marital.add("Single","single");
marital.add("Married","married");
marital.add("Divorced","divorced");
name.non_empty();
age.range(0,120);
}
};
But it still giving error:
myapp.cpp: In member function ‘void myapp::info_form()’:
myapp.cpp:20:9: error: ‘name’ was not declared in this scope
myapp.cpp:21:9: error: ‘sex’ was not declared in this scope
myapp.cpp:22:9: error: ‘marital’ was not declared in this scope
myapp.cpp:23:9: error: ‘age’ was not declared in this scope
myapp.cpp:24:9: error: ‘submit’ was not declared in this scope
myapp.cpp:24:9: note: suggested alternative:
/usr/local/include/cppcms/form.h:1574:20: note: ‘cppcms::widgets::submit’
myapp.cpp: At global scope:
myapp.cpp:43:37: error: no ‘void myapp::main(std::string)’ member function declared in class ‘myapp’
my_skin.tmpl:4:2: error: expected unqualified-id before ‘if’
my_skin.tmpl:8:3: error: expected unqualified-id before ‘else’
my_skin.tmpl:12:8: error: expected constructor, destructor, or type conversion before ‘<<’ token
my_skin.tmpl:13:2: error: expected unqualified-id before ‘{’ token
Related
I'm compiling a project with autotools and am using g++ in version gcc version 5.3.1 and boost version 1_63. After aclocal, autoconf, autoheader, automake --add-missing, I ran configure with some options, which succedded and build make a Makefile. Running make fails and gives me the error (excerpt):
In file included from /usr/local/include/boost/ratio/ratio.hpp:46:0,
from /usr/local/include/boost/chrono/duration.hpp:41,
from /usr/local/include/boost/chrono/time_point.hpp:33,
from /usr/local/include/boost/thread/lock_types.hpp:22,
from /usr/local/include/boost/thread/pthread/mutex.hpp:16,
from /usr/local/include/boost/thread/mutex.hpp:16,
from src/cosupport-initializer/cpp/BasicInitializer.cpp:39:
/usr/local/include/boost/integer_traits.hpp:83:46: error: 'CHAR_MIN' was not declared in this scope
public detail::integer_traits_base<char, CHAR_MIN, CHAR_MAX>
^
/usr/local/include/boost/integer_traits.hpp:83:56: error: 'CHAR_MAX' was not declared in this scope
public detail::integer_traits_base<char, CHAR_MIN, CHAR_MAX>
^
/usr/local/include/boost/integer_traits.hpp:83:64: error: template argument 2 is invalid
public detail::integer_traits_base<char, CHAR_MIN, CHAR_MAX>
^
/usr/local/include/boost/integer_traits.hpp:83:64: error: template argument 3 is invalid
/usr/local/include/boost/integer_traits.hpp:89:53: error: 'SCHAR_MIN' was not declared in this scope
public detail::integer_traits_base<signed char, SCHAR_MIN, SCHAR_MAX>
^
/usr/local/include/boost/integer_traits.hpp:89:64: error: 'SCHAR_MAX' was not declared in this scope
public detail::integer_traits_base<signed char, SCHAR_MIN, SCHAR_MAX>
^
/usr/local/include/boost/integer_traits.hpp:89:73: error: template argument 2 is invalid
public detail::integer_traits_base<signed char, SCHAR_MIN, SCHAR_MAX>
^
/usr/local/include/boost/integer_traits.hpp:89:73: error: template argument 3 is invalid
/usr/local/include/boost/integer_traits.hpp:95:58: error: 'UCHAR_MAX' was not declared in this scope
public detail::integer_traits_base<unsigned char, 0, UCHAR_MAX>
^
/usr/local/include/boost/integer_traits.hpp:95:67: error: template argument 3 is invalid
public detail::integer_traits_base<unsigned char, 0, UCHAR_MAX>
^
/usr/local/include/boost/integer_traits.hpp:131:47: error: 'SHRT_MIN' was not declared in this scope
public detail::integer_traits_base<short, SHRT_MIN, SHRT_MAX>
^
/usr/local/include/boost/integer_traits.hpp:131:57: error: 'SHRT_MAX' was not declared in this scope
public detail::integer_traits_base<short, SHRT_MIN, SHRT_MAX>
^
/usr/local/include/boost/integer_traits.hpp:131:65: error: template argument 2 is invalid
public detail::integer_traits_base<short, SHRT_MIN, SHRT_MAX>
^
/usr/local/include/boost/integer_traits.hpp:131:65: error: template argument 3 is invalid
/usr/local/include/boost/integer_traits.hpp:137:59: error: 'USHRT_MAX' was not declared in this scope
public detail::integer_traits_base<unsigned short, 0, USHRT_MAX>
^
/usr/local/include/boost/integer_traits.hpp:137:68: error: template argument 3 is invalid
public detail::integer_traits_base<unsigned short, 0, USHRT_MAX>
^
/usr/local/include/boost/integer_traits.hpp:143:45: error: 'INT_MIN' was not declared in this scope
public detail::integer_traits_base<int, INT_MIN, INT_MAX>
^
/usr/local/include/boost/integer_traits.hpp:143:54: error: 'INT_MAX' was not declared in this scope
public detail::integer_traits_base<int, INT_MIN, INT_MAX>
^
/usr/local/include/boost/integer_traits.hpp:143:61: error: template argument 2 is invalid
public detail::integer_traits_base<int, INT_MIN, INT_MAX>
^
/usr/local/include/boost/integer_traits.hpp:143:61: error: template argument 3 is invalid
/usr/local/include/boost/integer_traits.hpp:149:57: error: 'UINT_MAX' was not declared in this scope
public detail::integer_traits_base<unsigned int, 0, UINT_MAX>
^
/usr/local/include/boost/integer_traits.hpp:149:65: error: template argument 3 is invalid
public detail::integer_traits_base<unsigned int, 0, UINT_MAX>
^
/usr/local/include/boost/integer_traits.hpp:155:46: error: 'LONG_MIN' was not declared in this scope
public detail::integer_traits_base<long, LONG_MIN, LONG_MAX>
^
/usr/local/include/boost/integer_traits.hpp:155:56: error: 'LONG_MAX' was not declared in this scope
public detail::integer_traits_base<long, LONG_MIN, LONG_MAX>
^
/usr/local/include/boost/integer_traits.hpp:155:64: error: template argument 2 is invalid
public detail::integer_traits_base<long, LONG_MIN, LONG_MAX>
^
/usr/local/include/boost/integer_traits.hpp:155:64: error: template argument 3 is invalid
/usr/local/include/boost/integer_traits.hpp:161:58: error: 'ULONG_MAX' was not declared in this scope
public detail::integer_traits_base<unsigned long, 0, ULONG_MAX>
^
/usr/local/include/boost/integer_traits.hpp:161:67: error: template argument 3 is invalid
public detail::integer_traits_base<unsigned long, 0, ULONG_MAX>
This means e.g. that in /usr/local/include/boost/integer_traits.hpp on line 83, the constructor initialization fails:
template<>
class integer_traits<char>
: public std::numeric_limits<char>,
public detail::integer_traits_base<char, CHAR_MIN, CHAR_MAX>
{ };
This means in the file /usr/local/include/boost/integer_traits.hpp and headers included in it, there's no definition of CHAR_MIN. So this is a bug in boost? Or what am I missing here?
UPDATE
The relevant code excerpts. Before the move:
#include <CoSupport/compatibility-glue/nullptr.h>
#include <CoSupport/Initializer/BasicInitializer.hpp>
#include <boost/thread/mutex.hpp>
#include <cassert>
namespace CoSupport {
...
}
After the move:
#include <boost/thread/mutex.hpp>
#include <CoSupport/compatibility-glue/nullptr.h>
#include <CoSupport/Initializer/BasicInitializer.hpp>
#include <cassert>
namespace CoSupport {
...
}
This means in the file /usr/local/include/boost/integer_traits.hpp and headers included in it, there's no definition of CHAR_MIN
Which is as it should be - CHAR_MIN is defined in <climits>.
So this is a bug in boost? Or what am I missing here?
With 99% certainty, this is not a bug in boost. You probably have some include files of your own, in your project's include directories, masking climits or limits.h, or possibly another file which interger_traits.hpp includes and itself includes climits or limits.h.
Hi I've a program written in C++. When I compile it in Mac terminal with g++ compiler, it compiles and runs. But when I compile the same C++ program in Ubuntu terminal with g++ compiler, it Fails. I don't know why it happens.
g++ compiler version in Ubuntu is 4.7.3.
Here is my code sample
#include <iostream>
using namespace std;
#define IXSIZE 400
#define IYSIZE 400
#define IZSIZE 3
void putbyte(FILE *outf, unsigned char val)
{
unsigned char buf[1];
buf[0] = val;
fwrite(buf,1,1,outf);
}
void putshort(FILE *outf, unsigned short val)
{
unsigned char buf[2];
buf[0] = (val>>8);
buf[1] = (val>>0);
fwrite(buf,2,1,outf);
}
I get following error
seperate.cpp: In function ‘void putbyte(FILE*, unsigned char)’:
seperate.cpp:23:21: error: ‘fwrite’ was not declared in this scope
seperate.cpp: In function ‘void putshort(FILE*, short unsigned int)’:
seperate.cpp:32:21: error: ‘fwrite’ was not declared in this scope
seperate.cpp: In function ‘int putlong(FILE*, long unsigned int)’:
seperate.cpp:43:28: error: ‘fwrite’ was not declared in this scope
seperate.cpp: In function ‘short unsigned int getshort(FILE*)’:
seperate.cpp:49:22: error: ‘fread’ was not declared in this scope
seperate.cpp: In function ‘long int getlong(FILE*)’:
seperate.cpp:56:22: error: ‘fread’ was not declared in this scope
seperate.cpp: In function ‘int main(int, char**)’:
seperate.cpp:88:11: error: ‘stderr’ was not declared in this scope
seperate.cpp:88:69: error: ‘fprintf’ was not declared in this scope
seperate.cpp:89:9: error: ‘exit’ was not declared in this scope
seperate.cpp:93:30: error: ‘fopen’ was not declared in this scope
seperate.cpp:95:11: error: ‘stderr’ was not declared in this scope
seperate.cpp:95:61: error: ‘fprintf’ was not declared in this scope
seperate.cpp:96:9: error: ‘exit’ was not declared in this scope
seperate.cpp:101:22: error: ‘fgetc’ was not declared in this scope
seperate.cpp:114:18: error: ‘SEEK_CUR’ was not declared in this scope
seperate.cpp:114:26: error: ‘fseek’ was not declared in this scope
seperate.cpp:126:38: error: ‘fread’ was not declared in this scope
seperate.cpp:131:12: error: ‘fclose’ was not declared in this scope
seperate.cpp:138:25: error: ‘fopen’ was not declared in this scope
seperate.cpp:141:11: error: ‘stderr’ was not declared in this scope
seperate.cpp:141:54: error: ‘fprintf’ was not declared in this scope
seperate.cpp:142:9: error: ‘exit’ was not declared in this scope
seperate.cpp:153:36: error: ‘fwrite’ was not declared in this scope
seperate.cpp:162:11: error: ‘stderr’ was not declared in this scope
seperate.cpp:162:54: error: ‘fprintf’ was not declared in this scope
seperate.cpp:163:9: error: ‘exit’ was not declared in this scope
seperate.cpp:174:36: error: ‘fwrite’ was not declared in this scope
seperate.cpp:183:11: error: ‘stderr’ was not declared in this scope
seperate.cpp:183:54: error: ‘fprintf’ was not declared in this scope
seperate.cpp:184:9: error: ‘exit’ was not declared in this scope
seperate.cpp:195:36: error: ‘fwrite’ was not declared in this scope
dfo#ubuntu:~/Desktop/abc-master$ g++ -v
You need to include stdio.h for fwrite and FILE.
#include <stdio.h>
The standard allows headers to include other headers, but you cannot rely on these indirect includes. You need to explicitly include every header you intend to use.
I have one .h which has the class in it and two .cpp, One being the main and the other holding the functions.
My complier is giving me theses errors
Functions.cpp: In member function âvoid Flandre::add()â:
Functions.cpp:10:3: error: âcinâ was not declared in this scope
Functions.cpp:12:33: error: âstrlenâ was not declared in this scope
Functions.cpp:16:6: error: âcoutâ was not declared in this scope
Functions.cpp:16:57: error: âendlâ was not declared in this scope
Functions.cpp:21:7: error: âcoutâ was not declared in this scope
Functions.cpp:21:53: error: âendlâ was not declared in this scope
Functions.cpp:27:9: error: name lookup of âiâ changed for ISO âforâ scoping [-f
Functions.cpp:27:9: note: (if you use â-fpermissiveâ G++ will accept your code)
Functions.cpp:27:16: error: âKYUUâ was not declared in this scope
Functions.cpp:32:6: error: âcoutâ was not declared in this scope
Functions.cpp:32:57: error: âendlâ was not declared in this scope
Functions.cpp:35:17: error: expected primary-expression before â[â token
Functions.cpp:37:14: error: expected unqualified-id before â[â token
Functions.cpp:38:14: error: expected unqualified-id before â[â token
Functions.cpp:39:14: error: expected unqualified-id before â[â token
I think it has something to do with the #include header in Functions
Newprogram2.cpp
>#include <iostream>
#include <string>
#include "newprogram2.h"
Functions.cpp
Some parts are missing but I just want it to complied so I can get add() to work first.
#include "newprogram2.h"
newprogram2.h
#ifndef NEWPROGRAM2_H
#define NEWPROGRAM2_H
#include<string>
using namespace std;
#endif
You have to include the proper headers for the functions you want to use.
For cin, cout and endl you need to #include <iostream>, you forgot to do that in your 2nd .cpp file
The compiler doesn't recognize strlen as a function because it is not in <string> (see http://www.cplusplus.com/reference/string/) but in <string.h> (see http://www.cplusplus.com/reference/cstring/strlen/).
I suggest you use either size() or length(), these are in <string>, both of these can be called on std::string objects.
Functions.cpp:27:16: error: âKYUUâ was not declared in this scope
This error shows because you try to access a variable you declared in another .cpp file. The .cpp file you are trying to access it in doesn't know this variable. You can fix that by moving the variable into the header file.
Functions.cpp:27:9: error: name lookup of âiâ changed for ISO âforâ scoping
This can be fixed by changing this
for(i=0;i<=KYUU;i++)
to this
for(int i=0;i<=KYUU;i++)
Functions.cpp:35:17: error: expected primary-expression before â[â token
Functions.cpp:37:14: error: expected unqualified-id before â[â token
Functions.cpp:38:14: error: expected unqualified-id before â[â token
Functions.cpp:39:14: error: expected unqualified-id before â[â token
These errors show because you try to call functions directly on a class instead of an object instantiated from that class, like this Flandre[i].getid(). You cannot do that, make an object instead and call the functions on the object.
$ g++ -lthrift -Wall thriftfs.cpp cassandra_constants.cpp Cassandra.cpp cassandra_types.cpp -o thriftfs -I/usr/local/include/thrift -L/usr/local/lib
In file included from /usr/local/include/thrift/protocol/TProtocol.h:23:0,
from /usr/local/include/thrift/TProcessor.h:24,
from Cassandra.h:10,
from t`enter code here`hriftfs.cpp:4:
/usr/local/include/thrift/transport/TTransport.h:34:1: error: ‘uint32_t’ does not name a type
/usr/local/include/thrift/transport/TTransport.h:156:29: error: ISO C++ forbids declaration of ‘buf’ with no type [-fpermissive]
In file included from /usr/local/include/thrift/TProcessor.h:24:0,
from Cassandra.h:10,
from thriftfs.cpp:4:
/usr/local/include/thrift/protocol/TProtocol.h:184:1: error: ‘uint32_t’ does not name a type
In file included from Cassandra.h:10:0,
from thriftfs.cpp:4:
/usr/local/include/thrift/TProcessor.h:72:57: error: ‘uint32_t’ has not been declared
In file included from cassandra_types.h:11:0,
from Cassandra.h:11,
from thriftfs.cpp:4:
/usr/local/include/thrift/TApplicationException.h:94:3: error: ‘uint32_t’ does not name a type
In file included from Cassandra.h:11:0,
from thriftfs.cpp:4:
cassandra_types.h:85:16: error: ‘uint8_t’ does not name a type
In file included from Cassandra.h:11:0,
from thriftfs.cpp:4:
cassandra_types.h:142:3: error: ‘uint32_t’ does not name a type
In file included from Cassandra.h:11:0,
from thriftfs.cpp:4:
cassandra_types.h:1478:16: error: ‘uint8_t’ does not name a type
In file included from Cassandra.h:11:0,
from thriftfs.cpp:4:
cassandra_types.h:1812:3: error: ‘uint32_t’ does not name a type
In file included from thriftfs.cpp:4:0:
Cassandra.h:217:3: error: ‘uint32_t’ does not name a type
Cassandra.h:4857:35: error: ‘org::apache::thrift’ has not been declared
Cassandra.h:4857:62: error: expected ‘,’ or ‘...’ before ‘*’ token
Cassandra.h:4859:71: error: cannot declare pointer to ‘void’ member
Cassandra.h:4859:145: error: template argument 2 is invalid
Cassandra.h:4859:145: error: template argument 4 is invalid
Cassandra.h:4860:45: error: ‘org::apache::thrift’ has not been declared
Cassandra.h:4860:72: error: expected ‘,’ or ‘...’ before ‘*’ token
Cassandra.h:4935:42: error: ‘thrift’ is not a member of ‘org::apache’
Cassandra.h:4935:42: note: suggested alternative:
/usr/local/include/thrift/Thrift.h:75:37: note: ‘apache::thrift’
Cassandra.h:4935:42: error: ‘thrift’ is not a member of ‘org::apache’
Cassandra.h:4935:42: note: suggested alternative:
/usr/local/include/thrift/Thrift.h:75:37: note: ‘apache::thrift’
Cassandra.h:4935:77: error: template argument 1 is invalid
Cassandra.h:4935:105: error: ‘thrift’ is not a member of ‘org::apache’
Cassandra.h:4935:105: note: suggested alternative:
/usr/local/include/thrift/Thrift.h:75:37: note: ‘apache::thrift’
Cassandra.h:4935:105: error: ‘thrift’ is not a member of ‘org::apache’
Cassandra.h:4935:105: note: suggested alternative:
/usr/local/include/thrift/Thrift.h:75:37: note: ‘apache::thrift’
Cassandra.h:4935:140: error: template argument 1 is invalid
Cassandra.h: In constructor ‘org::apache::cassandra::CassandraProcessor::CassandraProcessor(boost::shared_ptr)’:
Cassandra.h:4898:49: error: assignment of read-only location ‘"login"[((org::apache::cassandra::CassandraProcessor*)this)->org::apache::cassandra::CassandraProcessor::processMap_]’
Cassandra.h:4898:49: error: cannot convert ‘void (org::apache::cassandra::CassandraProcessor::*)(int32_t, int) {aka void (org::apach
Add the following defines:
g++ -DHAVE_NETINET_IN_H -DHAVE_INTTYPES_H ...
Or add #include <stdint.h> before including Thrift.h in your code.
See the discussion at THRIFT-1326. The issue is suppposedly fixed in thrift 0.9.
It looks like your problem is a compiler issue.
It can't find the type "uint32_t"
There is another question on SO regarding this:
'uint32_t' identifier not found error
Quoted from user templatetypedef
This type is defined in the C header which is not currently
a part of the C++ standard. According to the Wikipedia page on the
header, it hasn't shipped with Visual Studio until VS2010.
In the meantime, you could probably fake up your own version of the
header by adding typedefs that map Microsoft's custom integer types to
the types expected by C. For example:
typedef __int32 int32_t; typedef unsigned __int32 uint32_t; /* ...
etc. ... */ Hope this helps!
I am getting the following error for STL files on GCC 4.1.2. And the same code works properly without any compilation errors on GCC 3.4.6.
I am including some built-in headers in my code that in turn include these STL files. Hence, I cannot modify the header files.
I compile it using the following:
gcc -I/grid/0/gs/java/jdk64/current/include -I/grid/0/gs/java/jdk64/current/include/linux -I/grid/0/tmp/direct/include/ydmg/ ydmg.cpp -I/grid/0/tmp/direct/include/ -o libydmg.so
Do I need to include some other parameter while compiling?
Could the compiler version be the cause of this problem?
The error is as follows:
/usr/lib/gcc/x86_64-redhat-linux/4.1.2/../../../../include/c++/4.1.2/bits/stl_vector.h:157: error: expected type-specifier
/usr/lib/gcc/x86_64-redhat-linux/4.1.2/../../../../include/c++/4.1.2/bits/stl_vector.h:157: error: expected `>'
/usr/lib/gcc/x86_64-redhat-linux/4.1.2/../../../../include/c++/4.1.2/bits/stl_vector.h:157: error: expected unqualified-id before â>â token
/usr/lib/gcc/x86_64-redhat-linux/4.1.2/../../../../include/c++/4.1.2/bits/stl_vector.h:932: error: expected â,â or â...â before â<â token
/usr/lib/gcc/x86_64-redhat-linux/4.1.2/../../../../include/c++/4.1.2/bits/stl_vector.h:932: error: âbool ytl::std::operator==(int)â must have an argument of class or enumerated type
/usr/lib/gcc/x86_64-redhat-linux/4.1.2/../../../../include/c++/4.1.2/bits/stl_vector.h:932: error: âbool ytl::std::operator==(int)â must take exactly two arguments
/usr/lib/gcc/x86_64-redhat-linux/4.1.2/../../../../include/c++/4.1.2/bits/stl_vector.h: In function âbool ytl::std::operator==(int)â:
/usr/lib/gcc/x86_64-redhat-linux/4.1.2/../../../../include/c++/4.1.2/bits/stl_vector.h:933: error: â__xâ was not declared in this scope
/usr/lib/gcc/x86_64-redhat-linux/4.1.2/../../../../include/c++/4.1.2/bits/stl_vector.h:933: error: â__yâ was not declared in this scope
/usr/lib/gcc/x86_64-redhat-linux/4.1.2/../../../../include/c++/4.1.2/bits/stl_vector.h:934: error: âequalâ is not a member of âytl::stdâ
/usr/lib/gcc/x86_64-redhat-linux/4.1.2/../../../../include/c++/4.1.2/bits/stl_vector.h: At global scope:
/usr/lib/gcc/x86_64-redhat-linux/4.1.2/../../../../include/c++/4.1.2/bits/stl_vector.h:949: error: expected â,â or â...â before â<â token
/usr/lib/gcc/x86_64-redhat-linux/4.1.2/../../../../include/c++/4.1.2/bits/stl_vector.h:949: error: âbool ytl::std::operator<(int)â must have an argument of class or enumerated type
/usr/lib/gcc/x86_64-redhat-linux/4.1.2/../../../../include/c++/4.1.2/bits/stl_vector.h:949: error: âbool ytl::std::operator<(int)â must take exactly two arguments
/usr/lib/gcc/x86_64-redhat-linux/4.1.2/../../../../include/c++/4.1.2/bits/stl_vector.h: In function âbool ytl::std::operator<(int)â:
/usr/lib/gcc/x86_64-redhat-linux/4.1.2/../../../../include/c++/4.1.2/bits/stl_vector.h:950: error: âlexicographical_compareâ is not a member of âytl::stdâ
/usr/lib/gcc/x86_64-redhat-linux/4.1.2/../../../../include/c++/4.1.2/bits/stl_vector.h:950: error: â__xâ was not declared in this scope
/usr/lib/gcc/x86_64-redhat-linux/4.1.2/../../../../include/c++/4.1.2/bits/stl_vector.h:951: error: â__yâ was not declared in this scope
/usr/lib/gcc/x86_64-redhat-linux/4.1.2/../../../../include/c++/4.1.2/bits/stl_vector.h: At global scope:
/usr/lib/gcc/x86_64-redhat-linux/4.1.2/../../../../include/c++/4.1.2/bits/stl_vector.h:956: error: expected â,â or â...â before â<â token
/usr/lib/gcc/x86_64-redhat-linux/4.1.2/../../../../include/c++/4.1.2/bits/stl_vector.h:956: error: âbool ytl::std::operator!=(int)â must have an argument of class or enumerated type
/usr/lib/gcc/x86_64-redhat-linux/4.1.2/../../../../include/c++/4.1.2/bits/stl_vector.h:956: error: âbool ytl::std::operator!=(int)â must take exactly two arguments
/usr/lib/gcc/x86_64-redhat-linux/4.1.2/../../../../include/c++/4.1.2/bits/stl_vector.h: In function âbool ytl::std::operator!=(int)â:
/usr/lib/gcc/x86_64-redhat-linux/4.1.2/../../../../include/c++/4.1.2/bits/stl_vector.h:957: error: â__xâ was not declared in this scope
/usr/lib/gcc/x86_64-redhat-linux/4.1.2/../../../../include/c++/4.1.2/bits/stl_vector.h:957: error: â__yâ was not declared in this scope
/usr/lib/gcc/x86_64-redhat-linux/4.1.2/../../../../include/c++/4.1.2/bits/stl_vector.h: At global scope:
/usr/lib/gcc/x86_64-redhat-linux/4.1.2/../../../../include/c++/4.1.2/bits/stl_vector.h:962: error: expected â,â or â...â before â<â token
/usr/lib/gcc/x86_64-redhat-linux/4.1.2/../../../../include/c++/4.1.2/bits/stl_vector.h:962: error: âbool ytl::std::operator>(int)â must have an argument of class or enumerated type
/usr/lib/gcc/x86_64-redhat-linux/4.1.2/../../../../include/c++/4.1.2/bits/stl_vector.h:962: error: âbool ytl::std::operator>(int)â must take exactly two arguments
/usr/lib/gcc/x86_64-redhat-linux/4.1.2/../../../../include/c++/4.1.2/bits/stl_vector.h: In function âbool ytl::std::operator>(int)â:
/usr/lib/gcc/x86_64-redhat-linux/4.1.2/../../../../include/c++/4.1.2/bits/stl_vector.h:963: error: â__yâ was not declared in this scope
/usr/lib/gcc/x86_64-redhat-linux/4.1.2/../../../../include/c++/4.1.2/bits/stl_vector.h:963: error: â__xâ was not declared in this scope
/usr/lib/gcc/x86_64-redhat-linux/4.1.2/../../../../include/c++/4.1.2/bits/stl_vector.h: At global scope:
/usr/lib/gcc/x86_64-redhat-linux/4.1.2/../../../../include/c++/4.1.2/bits/stl_vector.h:968: error: expected â,â or â...â before â<â token
/usr/lib/gcc/x86_64-redhat-linux/4.1.2/../../../../include/c++/4.1.2/bits/stl_vector.h:968: error: âbool ytl::std::operator<=(int)â must have an argument of class or enumerated type
/usr/lib/gcc/x86_64-redhat-linux/4.1.2/../../../../include/c++/4.1.2/bits/stl_vector.h:968: error: âbool ytl::std::operator<=(int)â must take exactly two arguments
/usr/lib/gcc/x86_64-redhat-linux/4.1.2/../../../../include/c++/4.1.2/bits/stl_vector.h: In function âbool ytl::std::operator<=(int)â:
/usr/lib/gcc/x86_64-redhat-linux/4.1.2/../../../../include/c++/4.1.2/bits/stl_vector.h:969: error: â__yâ was not declared in this scope
/usr/lib/gcc/x86_64-redhat-linux/4.1.2/../../../../include/c++/4.1.2/bits/stl_vector.h:969: error: â__xâ was not declared in this scope
/usr/lib/gcc/x86_64-redhat-linux/4.1.2/../../../../include/c++/4.1.2/bits/stl_vector.h: At global scope:
/usr/lib/gcc/x86_64-redhat-linux/4.1.2/../../../../include/c++/4.1.2/bits/stl_vector.h:974: error: expected â,â or â...â before â<â token
/usr/lib/gcc/x86_64-redhat-linux/4.1.2/../../../../include/c++/4.1.2/bits/stl_vector.h:974: error: âbool ytl::std::operator>=(int)â must have an argument of class or enumerated type
/usr/lib/gcc/x86_64-redhat-linux/4.1.2/../../../../include/c++/4.1.2/bits/stl_vector.h:974: error: âbool ytl::std::operator>=(int)â must take exactly two arguments
/usr/lib/gcc/x86_64-redhat-linux/4.1.2/../../../../include/c++/4.1.2/bits/stl_vector.h: In function âbool ytl::std::operator>=(int)â:
/usr/lib/gcc/x86_64-redhat-linux/4.1.2/../../../../include/c++/4.1.2/bits/stl_vector.h:975: error: â__xâ was not declared in this scope
/usr/lib/gcc/x86_64-redhat-linux/4.1.2/../../../../include/c++/4.1.2/bits/stl_vector.h:975: error: â__yâ was not declared in this scope
/usr/lib/gcc/x86_64-redhat-linux/4.1.2/../../../../include/c++/4.1.2/bits/stl_vector.h: At global scope:
/usr/lib/gcc/x86_64-redhat-linux/4.1.2/../../../../include/c++/4.1.2/bits/stl_vector.h:980: error: variable or field âswapâ declared void
/usr/lib/gcc/x86_64-redhat-linux/4.1.2/../../../../include/c++/4.1.2/bits/stl_vector.h:980: error: âytl::std::swapâ declared as an âinlineâ variable
/usr/lib/gcc/x86_64-redhat-linux/4.1.2/../../../../include/c++/4.1.2/bits/stl_vector.h:980: error: template declaration of âint ytl::std::swapâ
/usr/lib/gcc/x86_64-redhat-linux/4.1.2/../../../../include/c++/4.1.2/bits/stl_vector.h:980: error: âvectorâ was not declared in this scope
/usr/lib/gcc/x86_64-redhat-linux/4.1.2/../../../../include/c++/4.1.2/bits/stl_vector.h:980: error: expected primary-expression before â,â token
/usr/lib/gcc/x86_64-redhat-linux/4.1.2/../../../../include/c++/4.1.2/bits/stl_vector.h:980: error: expected primary-expression before â>â token
/usr/lib/gcc/x86_64-redhat-linux/4.1.2/../../../../include/c++/4.1.2/bits/stl_vector.h:980: error: â__xâ was not declared in this scope
/usr/lib/gcc/x86_64-redhat-linux/4.1.2/../../../../include/c++/4.1.2/bits/stl_vector.h:980: error: âvectorâ was not declared in this scope
/usr/lib/gcc/x86_64-redhat-linux/4.1.2/../../../../include/c++/4.1.2/bits/stl_vector.h:980: error: expected primary-expression before â,â token
/usr/lib/gcc/x86_64-redhat-linux/4.1.2/../../../../include/c++/4.1.2/bits/stl_vector.h:980: error: expected primary-expression before â>â token
/usr/lib/gcc/x86_64-redhat-linux/4.1.2/../../../../include/c++/4.1.2/bits/stl_vector.h:980: error: â__yâ was not declared in this scope
/usr/lib/gcc/x86_64-redhat-linux/4.1.2/../../../../include/c++/4.1.2/bits/stl_bvector.h:110: error: expected template-name before â<â token
/usr/lib/gcc/x86_64-redhat-linux/4.1.2/../../../../include/c++/4.1.2/bits/stl_bvector.h:110: error: expected `{' before â<â token
/usr/lib/gcc/x86_64-redhat-linux/4.1.2/../../../../include/c++/4.1.2/bits/stl_bvector.h:110: error: expected unqualified-id before â<â token
Any help would be appreciated.
Here is the C++ code.
I am calling the methods from ydmg and yut libraries using JNI.
This code is working perfectly fine on gcc 3.4.6. Its gives errors on gcc 4.1.2.
#include <stdio.h>
#include "ydmg/bd.h"
#include <jni.h>
#include "yut/string.h"
extern "C" int getAge();
JNIEXPORT jint JNICALL Java_ydmgBd_getAge(JNIEnv *, jobject)
{
ydmgBd bdObject;
yutString s = bdObject.getKeys();
printf("\ngetKeys() returns the key as : %s",s.c_str());
yutHash user;
yutString value = "abc";
yutString key ="login";
user.set(key,value);
ydmgBd bd1(user);
bool val = bd1.save(user);
if(val){
printf("\ntrue");
}else {
printf("\nfalse");
}
int age = bd1.getAge();
printf("\nAge : %d ",age);
printf("\nhi");
return 1;
}
int main(){
return 0;
}
If you compile cpp code with gcc and not with g++, you must link with -lstdc++, so that option is definitely missing.
However, the problem already occurs at the parsing step, so my suggestion is to check the namespaces... e.g. have a look at the error output:
...
ytl::std::operator!=
...
std should not be in your personal ytl namespace. You are doing something wrong with your includes.
One of your header files is almost certainly including:
#include <vector>
Before that line, add:
#undef max
And I believe your compiles will start working. This is happening b/c you are also using the C std library, which for some functions uses macros, and in this case, causes the preprocessor to freak out. I've seen this same error on Linux, and undefining that symbol was all i needed to get things compiling again.