This thread has been locked.

If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.

Include hpp file in C project , give errors

Hi

I have a General CCS , C project with normal .C and .H files. Compile it , it give no Errors.

When I creates C++ class (a .cpp file and a .hpp file) , the compiler is happy , no errors.

As soon as I include the .hpp file in any of my project files with n"#include xxx.hpp" file , it stats giving alots and lots of errors.

And I did used the CCS to greats the CLASS with File/New/Class.

Can any one helps me ?

I am new with CCS , and C++. I used CCS Version: 6.1.0.00104

Thank you

Maruis

  • Hi Maruis,
    Could you provide a small test case? The source and header files + project files if possible

    Thanks
    ki
  • #endif I think my problem is in my project in in C and then I add a C++ file and the compiler struggle with it.

    When I make a small test project it give me only 2 errors. The compiler does not have a problem with the cpp & hpp files. But when I include the hpp file in my system.h file it give the errors. See below.

    Sorry that I only replay now , but I am in GMT+2 time zone.

    Regards
    Maruis

    //main.c file -------------------------------------------------------------------------------------
    /*
    * main.c
    */

    #include "System.h"

    int main(void) {

    int i = 0;
    while(1)
    {
    i++;
    if (i == 1000)
    {
    i = 0;
    }
    }
    }
    //End of main.c

    //TestMyCpp.cpp file -------------------------------------------------------------------------------------
    /*
    * TestMyCpp.cpp
    *
    * Created on: 17 Jun 2015
    * Author: maruis
    */

    #include <TestMyCpp.hpp>

    namespace std {

    TestMyCpp::TestMyCpp() {
    // TODO Auto-generated constructor stub

    }

    TestMyCpp::~TestMyCpp() {
    // TODO Auto-generated destructor stub
    }

    } /* namespace std */
    //End of TestMyCpp.cpp

    //TestMyCpp.hpp// file -------------------------------------------------------------------------------------
    /*
    * TestMyCpp.hpp
    *
    * Created on: 17 Jun 2015
    * Author: maruis
    */

    #ifndef CODE_TESTMYCPP_HPP_
    #define CODE_TESTMYCPP_HPP_

    namespace std {

    class TestMyCpp {
    public:
    TestMyCpp();
    virtual ~TestMyCpp();
    };

    } /* namespace std */

    #endif /* CODE_TESTMYCPP_HPP_ */
    //End of TestMyCpp.hpp

    //System.h file -------------------------------------------------------------------------------------
    #ifndef _System_h_
    #define _System_h_
    /*****************************************************************************
    * Filename : System.h
    * Project : TestCpp
    *
    * DESCRIPTION
    * System Header include file's
    *
    *****************************************************************************/


    #include <stdbool.h>
    #include <stdint.h>
    #include <string.h>
    #include <stdlib.h>
    #include <stdio.h>


    #include "TestMyCpp.hpp"
    #endif
    //End of System.hpp
  • Try enabling the option "Treat C files as C++ files". This option can be found in the Build properties under 'Build -> Compiler -> Advanced Options -> Language Options'

    Thanks
    ki