Convert .cpp file into c file

Dear all
I have .cpp file associated with D3231. I have attached.cpp file for reference,
How can I convert below function in C

Is is enough for conversion here


//cpp file
bool DS3231::begin(void)
{
    Wire.begin();

    setBattery(true, false);

    t.year = 2000;
    t.month = 1;
    t.day = 1;
    t.hour = 0;
    t.minute = 0;
    t.second = 0;
    t.dayOfWeek = 6;
    t.unixtime = 946681200;

    return true;
}

// c file
 bool DS3231_begin()
 {
 	Wire.begin();

    setBattery(true, false);

    t.year = 2000;
    t.month = 1;
    t.day = 1;
    t.hour = 0;
    t.minute = 0;
    t.second = 0;
    t.dayOfWeek = 6;
    t.unixtime = 946681200;

    return true;
 	
 }


My first question is "Why?"
Arduino uses C++. Accessing C methods from C++ requires special flags/code to fix up the method calls.

1 Like

You use the DS3231 and the Wire class, so if you want to go the pure C, you'll need to rewrite the libraries to pure C too..

+1 with @drmpf, clarify why you would want to do this.