I have a line of source code:
time_t l1_QuoteTime;
I am getting the following error for it:
[BCC32 Error] QuoteDefs.h(18): E2303 Type name expected
Full parser context
Unit1.cpp(7): #include api\dasapi.h
dasapi.h(13): #include api\QuoteDefs.h
QuoteDefs.h(9): class st_L1Quotes
I have included <time.h>
. What am I missing here?
Code:
class st_L1Quotes
{
public:
char secsym[10];
char PrimExch;
int mstatus;
double l1_BidPrice;
int l1_BidSize;
double l1_AskPrice;
int l1_AskSize;
time_t l1_QuoteTime;
double l1_lastPrice;
double l1_todayhigh;
double l1_todaylow;
double l1_todayclose;
int l1_volume;
double l1_yclose;
double l1_todayopen;
double l1_LastBidPrice;
// this is used for show up/down arrow for NASDAQ NMS stocks;
};
Where is
<time.h>
(should that be<ctime>
) included w.r.t the"api/dasapi.h"
header?Indeed, the
QuoteDefs.h
header should probably#include
either<time.h>
or<ctime>
itself since it cannot be used unless that include is present. I can see how thetime_t
on the 11th line in the code snippet as formatted by me could be on the 9th line in your formatting of the code, but there isn't room for header protection guards or the necessary#include
.General tip:
Self-contained means that you should be able to write:
at the top of a file and the code should compile cleanly.
Idempotent means that it should not matter if the header is included twice. Usually, that wouldn't be done directly; rather the source would include the header directly and some other header would also include the header indirectly (or two other headers would include it indirectly). Think what a nuisance it would be if you could only include
<stdio.h>
or<iostream>
once!You can test idempotency by writing:
at the top of a file and the code should compile cleanly.
I even have a script called
chkhdr
to automate the test: