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;
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
I'm having problems trying to acces a enumeration field in my following code.
vtkSmartPointer<vtkGenericDataObjectReader> reader =
vtkSmartPointer<vtkGenericDataObjectReader>::New();
reader->SetFileName(file_name);
reader->Update();
vtkSmartPointer<vtkDataObject> vtk_data = reader->GetOutput();
vtkSmartPointer<vtkFieldData> points =
vtk_data->GetAttributesAsFieldData(vtkDataObject::AttributeTypes.POINT);
//points->PrintSelf(cout, 0);
However I get the following error:
error: expected primary-expression before ‘int’
vtk_data->GetAttributesAsFieldData(int(vtkDataObject::AttributeTypes.POINT));
For me ( using GCC 8.1 ) the following compiles without any error.
#include <vtkDataObject.h>
int main(){
auto a = vtkDataObject::AttributeTypes::POINT;
return 0;
}
This error is from the first line, peer : m_peerList
I don't know how to solve this, I tried everything.
const char * peer;
for (peer : m_peerList)
{
if (peer->IsAuth() || !peer->IsValid() || peer->GetChannel() != p->channel) //not the channel we are looking for!
continue;
TMapLocation kMapLocation;
thecore_memcpy(kMapLocation.alMaps, peer->GetMaps(), sizeof(kMapLocation.alMaps));
for (const auto midx :: kMapLocation.alMaps)
{
if (midx == p->lMapIndex)
{
//Get host, and convert to int
char host[16];
strlcpy(host, peer->GetPublicIP(), sizeof(kMapLocation.szHost));
lAddr = inet_addr(host);
//Target port
port = peer->GetListenPort();
break;
}
}
if (lAddr && port) //We already obtained them
break;
}
Error:
error: expected `;' before ':' token
If you can help me, I would be so much thank to you.
It must be compiled with the flag -std=c++11 or -std=c++14 or -std=c++17 . Also look at the second for-loop, it has an error.
There is a typo
for (const auto midx :: kMapLocation.alMaps)
should be
for (const auto midx : kMapLocation.alMaps).
with this code
var mat_add = gpu.createKernel(function(A, B) {
var sum = [];
for (var i=0; i<3; i++) {
sum.push(A[this.thread.y][i] + B[i][this.thread.x]);
}
return sum;
}).dimensions([2, 2]);
I am getting this error:
An error occurred compiling the shaders: ERROR: 0:141: '' : array size must be greater than zero
ERROR: 0:141: '[]' : array constructor supported in GLSL ES 3.00 and above only
ERROR: 0:141: 'constructor' : array constructor needs one argument per array element
ERROR: 0:141: '=' : Invalid operation for arrays
ERROR: 0:141: '=' : cannot convert from 'const array[1] of float' to 'highp float'
ERROR: 0:145: 'sum' : undeclared identifier
ERROR: 0:145: '' : methods supported in GLSL ES 3.00 and above only
ERROR: 0:145: 'push' : invalid method
This actually works:
var mat_mult = gpu.createKernel(function(A, B) {
var sum = 0;
for (var i=0; i<3; i++) {
sum += A[this.thread.y][i] * B[i][this.thread.x];
}
return sum;
}).dimensions([2, 1]);
Does anyone know how to fix this syntax error?
Thanks
i created python code to convert list into function getters : https://github.com/MhadhbiXissam/GLSL_LIST
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 ?