FreeRTOS Project Setup with error: expected ')' before string constant - stm32

I am starting a new project on a STM32L476 Nucleo board and planned to use FreeRTOS.
My initial project structure:
main.c
#include "project.h"
int main(void)
{
/* Configure the system clock */
Clock_Config();
/* Configure IOs */
GPIO_Config();
/* FreeRTOS Stuff */
NVIC_SetPriorityGrouping(3);
vTaskStartScheduler();
/* Should never get here! */
while (1){}
}
project.h
#ifndef PROJECT_H_
#define PROJECT_H_
/* MPU Files */
#include "stm32l4xx.h"
/* Project Files */
#include "gpio.h"
#include "clock.h"
/* FreeRTOS */
#include "FreeRTOS.h"
#include "queue.h"
#include "task.h"
#define TASKPRIO_STD ( tskIDLE_PRIORITY + 1 )
#define TICK_TASK_PERIOD_MS pdMS_TO_TICKS( 500 )
#endif /* PROJECT_H_ */
project.c
#include "project.h"
static void vSerialTask( void * pvParameters );
xTaskCreate( vSerialTask, "I2C", configMINIMAL_STACK_SIZE, NULL, TASKPRIO_STD, NULL);
static void vSerialTask( void *pvParameters ){
for( ;; )
{
}
}
I get a syntax error with this structure in xTaskCreate line: expected ')' before string constant
If I move xTaskCreate to my main.c and leave the task itself in my project.c (also have to delete static in this case) my project compiles successfully.
What is the problem here? I already saw working projects where xTaskCreate is not done within main.c so can't imagine this is the real problem?

You can't call the function outside another function and it is exactly what you try to do.
You can only call functions from another functions. The first function executed is main

Related

How to solve: error C2039: 'make_normal_of_point_with_normal_pmap': is not a member of 'CGAL'

I am using CGAL 4.12 and eigen 3.3.4 and trying to compile the Poisson_surface_reconstruction_3 example trough a Matlab mex function and am getting the following error:
C:\Users\u0116401\Documents\PRosPeRoS\Matlab_Code\mexTest\CGAL_poisson_reconstruction.cpp(70): error C2039: 'make_normal_of_point_with_normal_pmap': is not a member of 'CGAL'
C:\dev\CGAL-4.12\include\CGAL/IO/read_xyz_points.h(40): note: see declaration of 'CGAL'
C:\Users\u0116401\Documents\PRosPeRoS\Matlab_Code\mexTest\CGAL_poisson_reconstruction.cpp(70): error C3861: 'make_normal_of_point_with_normal_pmap': identifier not found
It seems 'make_normal_of_point_with_normal_pmap' can't be found. Does anyone know what is causing this issue?
The code that produces this error is:
/* mex headers */
#include <mex.h>
/* C++ headers */
#include <vector>
#include <fstream>
/* CGAL headers */
#include <CGAL/trace.h>
#include <CGAL/Exact_predicates_inexact_constructions_kernel.h>
#include <CGAL/Polyhedron_3.h>
#include <CGAL/IO/Polyhedron_iostream.h>
#include <CGAL/Surface_mesh_default_triangulation_3.h>
#include <CGAL/make_surface_mesh.h>
#include <CGAL/Implicit_surface_3.h>
#include <CGAL/IO/output_surface_facets_to_polyhedron.h>
#include <CGAL/Poisson_reconstruction_function.h>
#include <CGAL/Point_with_normal_3.h>
#include <CGAL/property_map.h>
#include <CGAL/IO/read_xyz_points.h>
#include <CGAL/compute_average_spacing.h>
// Types
typedef CGAL::Exact_predicates_inexact_constructions_kernel Kernel;
typedef Kernel::FT FT;
typedef Kernel::Point_3 Point;
typedef CGAL::Point_with_normal_3<Kernel> Point_with_normal;
typedef Kernel::Sphere_3 Sphere;
typedef std::vector<Point_with_normal> PointList;
typedef CGAL::Polyhedron_3<Kernel> Polyhedron;
typedef CGAL::Poisson_reconstruction_function<Kernel>Poisson_reconstruction_function;
typedef CGAL::Surface_mesh_default_triangulation_3 STr;
typedef CGAL::Surface_mesh_complex_2_in_triangulation_3<STr> C2t3;
typedef CGAL::Implicit_surface_3<Kernel, Poisson_reconstruction_function> Surface_3;
void mexFunction(int nlhs, mxArray *plhs[], /*Output variables */
int nrhs, const mxArray *prhs[]) /*Input variables */
{
PointList points;
std::ifstream stream("kitten.xyz");
if (!stream ||
!CGAL::read_xyz_points_and_normals(
stream,
std::back_inserter(points),
CGAL::make_normal_of_point_with_normal_pmap(std::back_inserter(points))))
}
The function is named make_normal_of_point_with_normal_map() (map not pmap) and it takes Point_with_normal as parameter. The call should be:
CGAL::make_normal_of_point_with_normal_map(Point_with_normal())

Platformio Error does not name a type

I have very simply code:
main.cpp
#include <Arduino.h>
#include "config.h"
Config c;
void setup() {
// put your setup code here, to run once:
}
void loop() {
// put your main code here, to run repeatedly:
}
config.h
#ifndef Config_h
#define Config_h
class Config{
public:
Config(){};
};
#endif
config.cpp
#include "config.h"
When I try to build project, I got the below error:
src\main.cpp:4:1: error: 'Config' does not name a type
What is wrong here?
I have found solution config.h => myconfig.h

How to add an header file in a C project on Eclipse?

I real need help over here, I have to do this ASCIITwitter project for an university's exam and I'm stucked with this problem:
I have to add a header file and a source file on my project of course, so first I tried some easy code to see if I'm capable to do this.
Just a program to do some square operations:
There's my code:
Twitter.h
#ifndef TWITTER_H_
#define TWITTER_H_
int square(int);
#endif /* TWITTER_H_ */
Twitter.c
#include "Twitter.h"
int square(int x)
{
return x*x;
}
main.c
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include "Twitter.h"
int main(void)
{
int y;
y=square(5);
printf("%d\n",y);
system("PAUSE");
}
But it give to me "undefined reference to 'square' and I really don't know how to fix this. I've tried searching on internet, but I'm working on windows, I don't have any makefile, I just want to make this work. Please help me.

C preprocessor: include based on define

How can I include a file or another, based on the value of a defined string?
This doesn't work:
#define VAR VALUE_A
#if VAR == "VALUE_A"
#include "a.h"
#elif VAR == "VALUE_B"
#include "b.h"
#endif
If it's important, I'm not actually defining VAR, I'm passing it down from the command-line via gcc -D NAME=VALUE.
The == operator does not compare strings. But you have a couple of other options to configure your includes. In addition to the solutions already mentioned in other answers, I like this one because I think it is quite self-explanatory.
/* Constant identifying the "alpha" library. */
#define LIBRARY_ALPHA 1
/* Constant identifying the "beta" library. */
#define LIBRARY_BETA 2
/* Provide a default library if the user does not select one. */
#ifndef LIBRARY_TO_USE
#define LIBRARY_TO_USE LIBRARY_ALPHA
#endif
/* Include the selected library while handling errors properly. */
#if LIBRARY_TO_USE == LIBRARY_ALPHA
#include <alpha.h>
#elif LIBRARY_TO_USE == LIBRARY_BETA
#define BETA_USE_OPEN_MP 0 /* You can do more stuff than simply include a header if needed. */
#include <beta.h>
#else
#error "Invalid choice for LIBRARY_TO_USE (select LIBRARY_ALPHA or LIBRARY_BETA)"
#endif
Your users can now compile with:
$ cc -DLIBRARY_TO_USE=LIBRARY_BETA whatever.c
You can use #ifdef or #ifndef for conditional includes.
#ifdef VALUE_A
#include "a.h"
#endif
#ifdef VALUE_B
#include "b.h"
#endif
The closest possilibility I can think of is to utilize third form of #include directive (C11 ยง6.10.2/4), namely define VAR with value, that holds actual header filename:
#define VAR "a.h"
then just use the following:
#include VAR

boost thread+signals: mem_fn error, invalid use of non-static member function

I am trying to get acquainted with boost thread and signals. I have therefore implemented this very simple code consisting of a class (Class1) implementing a thread. I'd like this class to provide services as result of signals reception. To this end I have just started to exploit the signal boost library but I am getting this error:
/home/andrea/libs/boost_1_50_0/boost/bind/mem_fn.hpp:359:22: error: invalid use of non-static member function
when I try to compile it in the Eclipse environment with gcc. Is there anything wrong with the singleton or is the binding to the instance method?
Here is Class1.cpp
#include "Class1.hpp"
#include <boost/thread.hpp>
#include <boost/date_time.hpp>
#include "Package1.hpp"
Class1::Class1(){
boost::thread thread(boost::bind(&Class1::classifierBehavior,this));
};
void Class1::classifierBehavior(){
service.run();
Package1Signals::getInstance()->signal1.connect(boost::bind(&Class1::method1, boost::ref(*this)));
};
void Class1::method1(Signal1 signal1){}
And Package1.hpp
#ifndef PACKAGE1_HEADER
#define PACKAGE1_HEADER
#include <boost/signal.hpp>
struct Signal1{
int foo;
};
class Package1Signals{
private:
Package1Signals();
static Package1Signals * instance;
public:
boost::signal<void (Signal1)> signal1;
static Package1Signals * getInstance(){
if(!instance){
instance = new Package1Signals();
}
return instance;
};
};
#endif
Your binder should have 1 argument:
boost::bind(&Class1::methpod1, boost::ref(*this), _1)