CppMSG_Cpp: Only for very general stuff. (gitter calls this the "Lobby") Please look for more specific rooms before posting here. https://gitter.im/CppMSG gives a list of the rooms. Thanks for keeping this organized. :) Use **during** our in-person and on-line meetings for chat and typing in what you are asking or talking about or links immediately relevant or remembering afterward. Please read this website about our two meetup groups : http://cppmsg.com
Hi,
I want to write a C Wrapper for C++.
the serial library is in C++ and I would like use some methods from the C++ serial library.
I have created a C++ wrapper header and a .cpp
source as wrapper.h
and wrapper.cpp
. Which goes as :
// wrapper.h
#ifdef __cplusplus
extern "C" {
#endif
#include <stdint.h>
typedef struct pserial pserial_t;
pserial_t * new_serial(char * port, uint32_t baud);
void delete_serial(pserial_t* d);
#ifdef __cplusplus
}
#endif
and wrapper.cpp
as :
#include "wrapper.h"
#include "serial/serial.h"
extern "C" {
pserial_t * new_serial(char * port, uint32_t baud) {
std::string _port = std::string(port);
return new serial::Serial(_port, baud);
}
void delete_serial(pserial_t* serl) {
delete static_cast<serial::Serial*>(serl);
}
}
but I am getting errors like :error: cannot convert ‘serial::Serial*’ to ‘pserial_t*’ {aka ‘pserial*’} in return
anderror: invalid static_cast from type ‘pserial_t*’ {aka ‘pserial*’} to type ‘serial::Serial*’
I am not getting the clue to resolve it, humbly request for some suggestions :)
@AliMarouf97
Hi developers,
Please review my C++ Genetic Algorithm Library
https://github.com/AliMarouf97/GeneticAlgorithm
The library provides a general genetic algorithm. It is simple, easy to use, and very fast. All you need to do is to define the fitness function and its variables. There are many examples of how to deal with classic genetic algorithms problems.