#include <iostream>
using namespace std;
#include "Interface.h"


void timer::start()
{
    if(! running)
    {
        begin=(unsigned int) clock();
        running=true;
    }
}

void timer::end()
{
    if(running)
    {
        finish=(unsigned int) clock();
        running=false;
    }
}

int timer::elapsed()
{
    if(running)
    {
        return((unsigned int) clock()-begin);
    }
    else
    {
        return finish-begin;
    }
}

int timer::output(unsigned int seconds)
{
    return seconds >= elapsed();
}

It says undefined reference to '_WinMain@16'

Salem commented: 24 posts, and STILL hasn't figured out code tags :( -7

Recommended Answers

All 5 Replies

You created a windows application project and don't have a WinMain function. WinMain is the entry point for windows applications. If you're writing a program that uses main instead of WinMain, change the project type to a console application. If you really do want a windows application, there has to be a WinMain function somewhere in your .cpp files.

anyone know how to change it a project into a console project in codeblocks?

all this is is a class. you need to implement it in an actual program.

int main()
{
     timer Timer;
     //use the timer here
     return 0;
}

I'm assuming you have the actual class in "Interface.h" and that these are just the functions.

yea that's in my test class

If the only error you get is undefined reference to winmain() then you did everything in your class right. All that error is telling you is that you don't have a main() or winmain() function for the program to start in. that will go away when you write a program that uses your class.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.