ctime does not compile

252 views
Skip to first unread message

corbinlc

unread,
Mar 12, 2012, 7:52:37 PM3/12/12
to android-ndk, corb...@gmail.com
Using the standalone toolchain, if I included ctime, I get the
following error:

::gmtime has not been declared
::localtime has not been declared

Any suggestions on how to fix this?

I tried getting rid of the

#undef gmtime
#undef localtime

as well as the

using ::gmtime
using ::localtime

which got rid of the error I mentioned, but led to issues inside the
code I was trying to port which used localtime, so it feels like that
wasn't the best approach.

Any help would be greatly appreciated.

corbinlc

unread,
Mar 12, 2012, 8:05:21 PM3/12/12
to android-ndk
This is using ndk 7b standalone toolchain.

Baodong Chen

unread,
Mar 12, 2012, 8:23:07 PM3/12/12
to andro...@googlegroups.com
On Tue, Mar 13, 2012 at 7:52 AM, corbinlc <corb...@gmail.com> wrote:
> Using the standalone toolchain, if I included ctime, I get the
> following error:
>
> ::gmtime has not been declared
> ::localtime has not been declared
>
> Any suggestions on how to fix this?
>
why not use #include <time.h>

> I tried getting rid of the
>
> #undef gmtime
> #undef localtime
>
> as well as the
>
> using ::gmtime
> using ::localtime
>
> which got rid of the error I mentioned, but led to issues inside the
> code I was trying to port which used localtime, so it feels like that
> wasn't the best approach.
>
> Any help would be greatly appreciated.
>

> --
> You received this message because you are subscribed to the Google Groups "android-ndk" group.
> To post to this group, send email to andro...@googlegroups.com.
> To unsubscribe from this group, send email to android-ndk...@googlegroups.com.
> For more options, visit this group at http://groups.google.com/group/android-ndk?hl=en.
>

corbinlc

unread,
Mar 13, 2012, 12:23:31 PM3/13/12
to android-ndk
The main reason is I am porting code. Ideally with no changes, or
very few, for the purpose of maintainability. My app is based on a
library that is not developed strictly for android and I have very
little control over that code. I am free to make changes to the
source, but would have to carry those changes forward.

What I tried is the equivalent of that, but I tried as you suggested
too. Both get me past the error listed but get me into other trouble
that I believe is related to time immediately.

Is this a known and expected issue? Is this a bug I should report?
Where do you report bugs or feature requests for the NDK?

Specifically, the error I got was this:

error: conversion from 'long unsigned int' to 'const my_time' is
ambiguous
note: candidates are: my_time(double)
note: my_time(time_t)

I am not an expert with ctime and time.h, but will do some research.
I would like to use ctime as the original code does, but can
completely wait for a fix if this is an accepted bug. But, I was
worried this new error was related to the one I originally posted.

Thanks,
Corbin

On Mar 12, 5:23 pm, Baodong Chen <chenbdche...@gmail.com> wrote:

Baodong Chen

unread,
Mar 14, 2012, 8:39:21 PM3/14/12
to andro...@googlegroups.com
there is no reason that ctime will not compile,i test it on ndk-r7b,it
compiled ok
test.cpp
#include <time.h>

void ctime_test_func(char out[64])
{
if (out) {
// get current time in seconds from 1970.1.1
time_t current = time(NULL);

char * p = ctime(&current);

if (p) {
strcpy(out, p);

corbinlc

unread,
Mar 26, 2012, 2:03:49 PM3/26/12
to android-ndk
I am only saying #include <ctime> causes a library to not compile.
This is a bug in my opinion. I was curious if there is a way to
report this bug.

On Mar 14, 5:39 pm, Baodong Chen <chenbdche...@gmail.com> wrote:
> On Wed, Mar 14, 2012 at 12:23 AM,corbinlc<corbi...@gmail.com> wrote:
> > The main reason is I am porting code.  Ideally with no changes, or
> > very few, for the purpose of maintainability.  My app is based on a
> > library that is not developed strictly for android and I have very
> > little control over that code.  I am free to make changes to the
> > source, but would have to carry those changes forward.
>
> > What I tried is the equivalent of that, but I tried as you suggested
> > too.  Both get me past the error listed but get me into other trouble
> > that I believe is related to time immediately.
>
> > Is this a known and expected issue?  Is this a bug I should report?
> > Where do you report bugs or feature requests for the NDK?
>
> > Specifically, the error I got was this:
>
> > error: conversion from 'long unsigned int' to 'const my_time' is
> > ambiguous
> > note: candidates are: my_time(double)
> > note:                 my_time(time_t)
>
> > I am not an expert with ctime and time.h, but will do some research.
> > I would like to use ctime as the original code does, but can
> > completely wait for a fix if this is an accepted bug.  But, I was
> > worried this new error was related to the one I originally posted.
>
> > Thanks,
> > Corbin
>
> > On Mar 12, 5:23 pm, Baodong Chen <chenbdche...@gmail.com> wrote:

elio francesconi

unread,
Nov 5, 2012, 10:10:07 AM11/5/12
to andro...@googlegroups.com
Hi corbinic,
Have you solved this issue?
I'm having the same issue with android-ndk-r8b-darwin-x86.tar.bz2, android-ndk-r7b-darwin-x86.tar.bz2 or android-ndk-r6b-darwin-x86.tar.bz2.

It is a very strange issue and it is platform dependent, because ctime works on linux enviroment but not on mac os.

Thanks
Elio

2012/3/26 corbinlc <corb...@gmail.com>
Reply all
Reply to author
Forward
0 new messages