I have this function. I created it with libxml2 and std::string library.
#ifndef KNIHOVNA_H
#define KNIHOVNA_H
#include <string>
#include <libxml/tree.h>
std::string hledaniString(int index,xmlDocPtr sharedString)
{
std::string Istring;
xmlAttrPtr attr;
xmlChar *attrValue;
xmlNodePtr nodeLevel1 = sharedString->children;
int maxValue;
int aIndex;
attr = xmlHasProp(nodeLevel1, (const xmlChar*)"uniqueCount");
if (attr !=NULL)
{
attrValue = xmlGetProp(nodeLevel1, (xmlChar *)"uniqueCount");
}
else return "Chybny format souboru. Spatny soubor sharedStrings.xml.";
nodeLevel1 = nodeLevel1->children;
maxValue = atoi((const char *) attrValue);
xmlFree(attrValue);
if (maxValue<=index) return "Chybny format souboru. Spatny soubor sharedStrings.xml.";
for (aIndex = 0;aIndex < index; aIndex++ )
{
nodeLevel1 = nodeLevel1->next;
}
nodeLevel1 = nodeLevel1->children;
attrValue = xmlNodeGetContent(nodeLevel1);
xmlFree(attrValue);
attrValue = xmlNodeGetContent(nodeLevel1);
Istring = (char *) attrValue;
xmlFree(attrValue);
return Istring;
#endif // KNIHOVNA_H
I use it in Code Block project where is everything ok and in qt creator project where I get these errors:
/usr/include/c++/4.8/string:38: In file included from /usr/include/c++/4.8/string:38:0,
/usr/include/c++/4.8/bits/stl_relops.h:-1: In function 'std::string getString(int, xmlDocPtr)':
/usr/include/c++/4.8/bits/stl_relops.h:67: error: expected '=' before '__attribute__'
/usr/include/c++/4.8/bits/stl_relops.h:67: error: expected identifier before '__attribute__'
/usr/include/c++/4.8/bits/stl_relops.h:67: error: expected ';' before '__attribute__'
/usr/include/c++/4.8/bits/stl_relops.h:67: error: expected primary-expression before '__attribute__'
/usr/include/c++/4.8/bits/stl_relops.h:67: error: expected ';' before '__attribute__'
/home/daffy/qt projektz/revize/main.cpp:15: error: expected '}' at end of input
Could someone help me please ?
Related
i have code. but I can not understand why he swears?
This is line 17
if (!empty($city_result = $this->model_module_novapochta->getCity($this->request->post['novaposhta_key']))) {
**Parse error: syntax error, unexpected '=', expecting ')' in /home/s2332/***.com/www/admin/controller/shipping/novaposhta.php on line 17**
if (!empty($this->request->post['refresh']) && !empty($this->request->post['novaposhta_key'])) {
if (!empty($city_result = $this->model_module_novapochta->getCity($this->request->post['novaposhta_key']))) {
$this->session->data['error'] = $city_result;
} elseif (!empty($address_result = $this->model_module_novapochta->getAdress($this->request->post['novaposhta_key']))) {
$this->session->data['error'] = $address_result;
}
};
Your if statement is wrong...
You have write:
if (!empty($city_result = $this->model_module_novapochta->getCity($this->request->post['novaposhta_key']))) {
must be:
$city_result = $this->model_module_novapochta->getCity($this->request->post['novaposhta_key']);
if (!empty($city_result)) {
//your code here
So bellow follows a function that will then be called for a main program. My problem is, if I do not declare challInfo as a struct, upon compiling, it will return:
ERROR on page PhotoPoints at line 5, col 21: ‘challInfo’ was not declared in this scope
Meanwhile, if I do declare it (as it is bellow) it returns:
ERROR on page PhotoPoints at line 5, col 30: expected primary-expression before ‘.’ token ERROR on page PhotoPoints at line 7, col 52: expected primary-expression before ‘.’ token ERROR on page PhotoPoints at line 8, col 28: expected primary-expression before ‘.’ token ERROR on page PhotoPoints at line 8, col 60: expected primary-expression before ‘.’ token ERROR on page PhotoPoints at line 8, col 109: expected primary-expression before ‘.’ token ERROR on page PhotoPoints at line 9, col 31: expected primary-expression before ‘.’ token ERROR on page PhotoPoints at line 9, col 66: expected primary-expression before ‘.’ token ERROR on page PhotoPoints at line 9, col 118: expected primary-expression before ‘.’ token ERROR on page PhotoPoints at line 14, col 35: expected primary-expression before ‘.’ token ERROR on page PhotoPoints at line 14, col 57: expected primary-expression before ‘.’ token
I have been looking around the internet, including Stack Overflow, and it always seems the answer to this is specific to each case. I admit I'm lost. Can you help?
float PhotoPoints() {
struct challInfo;
bool isFacingOther();
bool sphereInDark();
bool isCameraOn = challInfo.camera.cameraOn;
bool isFacingOtherResult = isFacingOther();
bool isOppNotInDarkZone = !sphereInDark(challInfo.other.zrState);
bool myMirror = challInfo.me.mirrorTime != 0 && challInfo.me.mirrorTime + ITEM_MIRROR_DURATION > challInfo.currentTime;
bool otherMirror = challInfo.other.mirrorTime != 0 && challInfo.other.mirrorTime + ITEM_MIRROR_DURATION > challInfo.currentTime;
float picturePointValue = 0;
if (isCameraOn && isFacingOtherResult && isOppNotInDarkZone && !myMirror)
{
float bet[3], distance;
mathVecSubtract(bet, challInfo.me.zrState, challInfo.other.zrState, 3);
distance = mathVecMagnitude(bet, 3);
if (distance < PHOTO_MIN_DISTANCE) {
DEBUG(("Not a good shot: too close to the other satellite | "));
return 0.0;
}
picturePointValue = 2.0 + 0.1/(distance - PHOTO_MIN_DISTANCE + 0.1);
if(otherMirror){
picturePointValue = 0;
DEBUG(("Not a good shot: Opposing mirror active |"));
}
}
else if(!isCameraOn){
DEBUG(("Not a good shot: camera off |"));
}
else if(myMirror){
DEBUG(("Not a good shot: my mirror's in the way |"));
}
else if(!isFacingOtherResult) {
DEBUG(("Not a good shot: not facing the other satellite | "));
}
else if(!isOppNotInDarkZone){
DEBUG(("Not a good shot: opponent in dark zone |"));
}
return picturePointValue;
}
You have an error here for every time you have referenced a member of challInfo. You need to include a full declaration so that the compiler can tell what is inside of the struct, nut simply that it is a struct. You have only provided a forward declaration.
struct challInfo;
Should have a definition like:
// Define your camera object
struct Camera {
bool isCameraOn;
}
// Define the object type of challInfo
struct PhotographyInfo {
Camera camera
}
then you can use the object:
PhotographyInfo challInfo{};
challInfo.camera = Camera{true};
you define a struct challInfo then after assign the bool isCameraOn to a data member of that struct. Here is the problem I think you are a bit confused about structs. A struct is in many ways like a class. Where for example I could put something like this in a header file with other class definitions.
struct Example_struct{
int data_mem_a;
bool data_mem_b;
}
Then perhaps use this struct in a class prototype
class example_class{
private:
example_struct struct_instance;
public:
bool get_a_from_struct(){return struct_instance.data_mem_a;};
In your case you would want to make sure that the challInfo struct is defined somewhere, and then declare an instance of it.
challInfo CI;
bool isCameraOn = CI.camera.caneraOn;
I would like to run an application in qt creator. But when i click on build, it showing error in carddetect.cpp
The error occurs here: void CardDetect::aamvaIssuerList()
But I can't find out what that error is.
124: error: C2059: syntax error : '{'
124: error: C2143: syntax error : missing ';' before '{'
124: error: C2143: syntax error : missing ';' before '}'
This is my code:
#include "carddetect.h"
#include <QDebug>
void CardDetect::aamvaIssuerList(){
issuerList [ "636026" ] = (struct issuer) {"Arizona", "AZ", "L"};
issuerList [ "0636021"] = (struct issuer) { "Arkansas", "AR", "" };
issuerList [ "636014" ] = (struct issuer) { "California", "CA", "L" };
issuerList [ "636020" ] = (struct issuer) { "Colorado", "CO", "NN-NNN-NNNN" };
issuerList [ "636010" ] = (struct issuer) { "Florida", "FL", "LNNN-NNN-NN-NNN-N" };
issuerList [ "636018" ] = (struct issuer) { "Iowa", "IA", "NNNLLNNNN" };
}
and carddetect.h is
#ifndef CARDDETECT_H
#define CARDDETECT_H
#include <QMap>
#include "magcard.h"
struct issuer {
QString name;
QString abbreviation;
QString format;
};
class CardDetect {
public:
CardDetect( MagCard *_card = 0 );
void setCard( MagCard *_card );
private:
MagCard *card;
void processCard();
void luhnCheck();
void creditCardCheck();
void aamvaCardCheck( QString expDate );
void aamvaIssuerList();
QMap<QString,struct issuer> issuerList;
};
#endif // CARDDETECT_H
That code working #keltar
but now in this function
void CardDetect::aamvaCardCheck( QString expDate ) {
if( card->encoding == IATA )
return; //we're only going to support ABA for now
struct issuer issuerInfo;
QString iin = card->accountNumber.left( 6 );
issuerInfo = issuerList.value( iin );
if( issuerInfo.name.isEmpty() ) {
iin = card->accountNumber.mid( 1, 6 );
issuerInfo = issuerList.value( iin );
if( issuerInfo.name.isEmpty() )
return; // this is not a known AAMVA card, abort
}
It showing error
error: C2512: 'issuer' : no appropriate default constructor available
error: C2512: 'issuer::issuer' : no appropriate default constructor available
in struct issuer issuerInfo;
Since you cannot use compound literals, here is an example of how it could be done:
Add constructor to your structure:
struct issuer {
issuer(const char *nm, const char *abbr, const char *fmt) : name(nm),
abbreviation(abbr), format(fmt) {}
QString name;
QString abbreviation;
QString format;
};
And change your function to:
void CardDetect::aamvaIssuerList(){
issuerList [ "636026" ] = issuer("Arizona", "AZ", "L");
// same for the rest of the lines
}
There are other ways to do the same, of course.
I have an AVOption structure:
static const AVOption options[] = {
COMMON_OPTIONS // error here
{ NULL }
};
and COMMON_OPTIONS is defined as:
#define COMMON_OPTIONS \
{ "interp", "select interpolation mode", OFFSET(interpolation), AV_OPT_TYPE_INT, {.i64=INTERPOLATE_TETRAHEDRAL}, 0, NB_INTERP_MODE-1, FLAGS, "interp_mode" }, \
{NULL}
I am getting an error:
2>c:\users\awki6\desktop\ffmpeg\libavfilter\vsrc_testsrc.cpp(98): error C2143: syntax error : missing '}' before '.'
Your COMMON_OPTIONS macro has already the { NULL } and does not ends with a ,, so:
static const AVOption options[] = {
COMMON_OPTIONS
};
will solve your problem.
Past answer before the edit:
Even if we don't know what does COMMON_OPTIONS expand to, I guess that you just miss the comma after it:
static const AVOption options[] = {
COMMON_OPTIONS,
// ^
{ NULL }
};
program:
CCompussGradientOperator dlg;
string p = "preqitt";
string k = "Kirnch";
string r3 = "Robison";
f(dlg.DoModal() == IDOK)
{
CDib dib = m_Dib;
BOOL ret = FALSE;
if(dlg.m_Combo_Operators == p )
{
switch(dlg.m_nFunction)
{
case 0: ret ;
}
}
}
error:
Error 18 error C2065: 'string' : undeclared identifier d:\2nd\imagetool\imagetooldoc.cpp 870 1 ImageTool
string is a data type then why it does make me error.. its strange for me...
any one can help me ..thanks
Have you included <string> header ? Also it is in namespace std.
Change string to std::string. Also, do you have #include <string> at the top of the source file?