Discussion:
error C3861: 'time': identifier not found
dan g.
2011-01-26 10:15:41 UTC
Permalink
Hello - I apologize as this comes off as somewhat more of a C++ question, but
after banging my head against this all night, I decided to ask if someone else
had experienced it.

I had a fairly large project going with mysql++ - working fine for a couple
years - a client/server game type thing.

Anyway tonight I decided to break off the database portion of the code and make
it into a library so i can use it in a world builder/editor GUI app i'm making
as well.

At some point during this process, including mysql++.h in the new library i made
started causing this compile error:

1>d:\mysql++\lib\cpool.h(221) : error C3861: 'time': identifier not found

I've been looking at any project settings differences I can between the two but
I'm drawing a blank.. I searched for this error in the mailing list search
engine and found nothing.

Any recommendations?

Thanks.
--
MySQL++ Mailing List
For list archives: http://lists.mysql.com/plusplus
To unsubscribe: http://lists.mysql.com/plusplus?unsub=gcdmc-***@m.gmane.org
Tomalak Geret'kal
2011-01-26 10:21:07 UTC
Permalink
Post by dan g.
Anyway tonight I decided to break off the database portion of the code and make
it into a library so i can use it in a world builder/editor GUI app i'm making
as well.
At some point during this process, including mysql++.h in the new library i made
1>d:\mysql++\lib\cpool.h(221) : error C3861: 'time': identifier not found
I've been looking at any project settings differences I can between the two but
I'm drawing a blank.. I searched for this error in the mailing list search
engine and found nothing.
Dan,

The line contains a reference to standard time(0), which is
properly brought into scope at the top of cpool.h with

#include <time.h>

Idiomatically, this should be

#include <ctime>

However, both are perfectly valid. Seems like perhaps your
toolchain's standard library headers are not in the right place?

Only thing I can think of.

Tom
--
MySQL++ Mailing List
For list archives: http://lists.mysql.com/plusplus
To unsubscribe: http://lists.mysql.com/plusplus?unsub=gcdmc-***@m.gmane.org
Jonathan Wakely
2011-01-26 10:22:46 UTC
Permalink
Post by dan g.
At some point during this process, including mysql++.h in the new library i made
1>d:\mysql++\lib\cpool.h(221) : error C3861: 'time': identifier not found
Did you try looking on line 221 of cpool.h ?

It's trying to use the standard library function time(), which is
declared in <time.h>, which is included by cpool.h on line 28

If <time.h> doesn't declare time() on your system, then either your
development environment is totally borked, or you've got another file
called time.h in your include paths and it doesn't declare time().

I suspect it's the latter - and the answer is that you should not
reuse the names of standard library headers for your own files.
--
MySQL++ Mailing List
For list archives: http://lists.mysql.com/plusplus
To unsubscribe: http://lists.mysql.com/plusplus?unsub=gcdmc-***@m.gmane.org
dan g.
2011-01-26 10:38:51 UTC
Permalink
Wow, thank you, I did accidentally have an include path that went one too deep
into ZThread's includes structure.. and there was a Time.h in there.


----- Original Message ----
From: Jonathan Wakely <***@kayari.org>
To: dan g. <***@yahoo.com>
Cc: ***@lists.mysql.com
Sent: Wed, January 26, 2011 2:22:46 AM
Subject: Re: error C3861: 'time': identifier not found
Post by dan g.
At some point during this process, including mysql++.h in the new library i made
1>d:\mysql++\lib\cpool.h(221) : error C3861: 'time': identifier not found
Did you try looking on line 221 of cpool.h ?

It's trying to use the standard library function time(), which is
declared in <time.h>, which is included by cpool.h on line 28

If <time.h> doesn't declare time() on your system, then either your
development environment is totally borked, or you've got another file
called time.h in your include paths and it doesn't declare time().

I suspect it's the latter - and the answer is that you should not
reuse the names of standard library headers for your own files.
--
MySQL++ Mailing List
For list archives: http://lists.mysql.com/plusplus
To unsubscribe: http://lists.mysql.com/plusplus?unsub=gcdmc-***@m.gmane.org
Jonathan Wakely
2011-01-26 10:47:32 UTC
Permalink
Post by dan g.
Wow, thank you, I did accidentally have an include path that went one too deep
into ZThread's includes structure.. and there was a Time.h in there.
Eurgh - the perils of case independent filesystems!
--
MySQL++ Mailing List
For list archives: http://lists.mysql.com/plusplus
To unsubscribe: http://lists.mysql.com/plusplus?unsub=gcdmc-***@m.gmane.org
Tomalak Geret'kal
2011-01-26 10:53:26 UTC
Permalink
Post by Jonathan Wakely
Post by dan g.
Wow, thank you, I did accidentally have an include path that went one too deep
into ZThread's includes structure.. and there was a Time.h in there.
Eurgh - the perils of case independent filesystems!
And of stupid header names. And of having broken include
paths. :)

Tom
--
MySQL++ Mailing List
For list archives: http://lists.mysql.com/plusplus
To unsubscribe: http://lists.mysql.com/plusplus?unsub=gcdmc-***@m.gmane.org
Chris Frey
2011-01-26 21:37:59 UTC
Permalink
Post by Tomalak Geret'kal
Post by Jonathan Wakely
Post by dan g.
Wow, thank you, I did accidentally have an include path that went one too deep
into ZThread's includes structure.. and there was a Time.h in there.
Eurgh - the perils of case independent filesystems!
And of stupid header names. And of having broken include
paths. :)
I dare to diverge from the MySQL++ topic to say that there's nothing
stupid about having a header named time.h.

You just need to realize that, to use it, use:

#include "time.h"

And to use the system version, use:

#include <time.h>

If you keep your application or library headers in their own subdirectory,
such as:

mylib/mylib.h
mylib/time.h
mylib/help.h

Then you can include properly, like:

#include "mylib/time.h"

or, if the directory in which the mylib/ directory resides is in your include
search path:

#include <mylib/mylib.h>

Note that when mylib.h itself needs to include its own time.h, it just
does the same thing:

#include "time.h"

And everything works out as it should.

It is when programmers don't understand the flexibility of these include
rules that problems occur. There is nothing magical about the filenames.

The rule is:

#include "something.h"

searches first in the same directory as the file that is doing the including.
That is, any quoted includes inside mylib/mylib.h will first be searched for
in the mylib/ directory, even if some .c file in some other random directory
was the file that first included <mylib/mylib.h>.

While:

#include <something.h>

will search first in the compiler's include path list.

Have fun,
- Chris
--
MySQL++ Mailing List
For list archives: http://lists.mysql.com/plusplus
To unsubscribe: http://lists.mysql.com/plusplus?unsub=gcdmc-***@m.gmane.org
Tomalak Geret'kal
2011-01-27 01:53:03 UTC
Permalink
Post by Chris Frey
Post by Tomalak Geret'kal
Post by Jonathan Wakely
Post by dan g.
Wow, thank you, I did accidentally have an include path that went one too deep
into ZThread's includes structure.. and there was a Time.h in there.
Eurgh - the perils of case independent filesystems!
And of stupid header names. And of having broken include
paths. :)
I dare to diverge from the MySQL++ topic to say that there's nothing
stupid about having a header named time.h.
[chop]

Chris

Regardless, I can't imagine what a library-specific header
"time.h" would provide that doesn't suggest it does the same
thing as the standard header of the same name.

I would suggest that the library header needs a more
descriptive name; they're indeed not "magical", but
filenames sure as hell are useful. Or they should be.

Tom
--
MySQL++ Mailing List
For list archives: http://lists.mysql.com/plusplus
To unsubscribe: http://lists.mysql.com/plusplus?unsub=gcdmc-***@m.gmane.org
Jonathan Wakely
2011-01-27 09:46:33 UTC
Permalink
Regardless, I can't imagine what a library-specific header "time.h" would
provide that doesn't suggest it does the same thing as the standard header
of the same name.
You need to imagine harder ;-)

#include <units/energy.h>
#include <units/time.h>
#include <units/distance.h>

In principle I agree with Chris, problems come when the convention
isn't followed (which might be done by third-party code you don't
control) or when people use -I. or -Iunits and don't use the directory
names in the #include statement.
--
MySQL++ Mailing List
For list archives: http://lists.mysql.com/plusplus
To unsubscribe: http://lists.mysql.com/plusplus?unsub=gcdmc-***@m.gmane.org
Loading...