What does it mean when it say inconsistent DLL Linkage

I have this simple program, that I am using to test #include<ctime>, it works but when I compile it says- Warning 4273 'clock' inconsistent dll linkage.
what is the compiler trying to tell me and how do I fix it?


1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
#include <ctime> 
#include <iostream>
using namespace std; 
clock_t clock(void);

int main()
{
    clock_t start, finish;
    start = clock();  
    cin.get(); 
    finish = clock();
    cout << "This is the time " << (double)((finish -start)/CLOCKS_PER_SEC);
    cin.get();
    return(EXIT_SUCCESS);
}
Cire: I removed it and it works. But what it the reason why it worked? considering that it is a book example.
@mendozae
The better question is why was it there in the first place?
What it looks like that line is supposed to accomplish is prototype a function. The reason it would throw up an error is because obviously somewhere in <ctime> it was already declared (slightly differently.)

Also, it's not uncommon for there to be mistakes in books.

EDIT:
One more thing, different compilers handle things slightly differently. It's possible whoever wrote the book had a compiler that allowed that to work, while yours doesn't.
Last edited on
Here, I would say it is a mistake. You should never declare someone elses function.

As clock_t clock() is part of the standard library, it is their business to declare and define their function. You should include their header and let them declare it.

Andy

PS Unless you're forced to, to work round some kind of problem.
Compiler will use prototype to find functions that are defined somewhere. If you are to find the house with red roof, and if there is only one house with red roof in the town, you can find it. Prototyping same function twice with slightly different detail is same as I telling you "Hey, actually the house you are finding has blue roof". You will be get confused what house to go now.
Thanks for all the comments. I checked the content of time.h and everybody is right it is already in the header file. Since I included the <ctime> header and in <ctime>it included <time.h> then declaring clock() is a duplication.

I like the analogy used by kg though.
Topic archived. No new replies allowed.