I'm writing a C application using allegro and I need some C++ functionnalities so i wrote a C/C++ interface for my functions using extern "C" But it gives me a lot of warning for implicit declaration of theese functions
Here is my code in lists.h
#ifndef LISTS_HPP_INCLUDED
#define LISTS_HPP_INCLUDED
#include "entities.h"
#include "engine.h"
#ifdef __cplusplus
extern "C"
{
int cloneList_size(void);
int colList_size(void);
int scene_size(void);
void cloneList_clear(void);
void colList_clear(void);
void scene_clear(void);
void push_back_cloneList(Object *object);
void push_back_colList(t_collision *col);
void push_back_scene(Object *object);
void remove_cloneList(Object *object);
void remove_scene(Object *object);
Object* Scene(int nbr);
Object* CloneList(int nbr);
t_collision* ColList(int nbr);
}
#endif // __cplusplus
#endif // LISTS_HPP_INCLUDED
Here is my code in lists.cpp
#include "lists.h"
#include <iostream>
#include <vector>
#include <stdexcept>
std::vector<Object *> scene;
std::vector<t_collision *> colList;
std::vector<Object *> cloneList;
int cloneList_size(void)
{ //..
}
//And all other functions here
I can't include lists.h in my main.c or I have an error because the C compiler doesn't recognize the extern "C" part
If I don't include lists.h it works but with many implicit declaration of function warnings..
I'm using Codeblocks 13.12 and I don't know how to enable the C++ compilation option as someone suggested in another forum when I googled my problem.
What am I doing wrong and what should I do to correct these warnings..
extern "C"? What is compiler's error and warning message? - ikh