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
clock_t start, finish;
start = clock();
finish = clock();
cout << "This is the time " << (double)((finish -start)/CLOCKS_PER_SEC);
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.
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.
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.