[Home] [Downloads] [Search] [Help/forum]


Register forum user name Search FAQ

Gammon Forum

[Folder]  Entire forum
-> [Folder]  SMAUG
. -> [Folder]  SMAUG coding
. . -> [Subject]  Warnings when trying to compile in C++

Warnings when trying to compile in C++

It is now over 60 days since the last post. This thread is closed.     [Refresh] Refresh page


Pages: 1 2  

Posted by Metsuro   USA  (389 posts)  [Biography] bio
Date Tue 12 Dec 2006 09:09 PM (UTC)
Message
I got this warning.

changes.c: In function `char * current_date()':
changes.c:81: warning: `%x' yields only last 2 digits of year in some locales


the line is this...

 strftime( buf, 128, "%x", datetime );


Not all to familiar with this, but I'm just trying to clean it up, and dont know whats wrong?

Everything turns around in the end
[Go to top] top

Posted by Zeno   USA  (2,871 posts)  [Biography] bio
Date Reply #1 on Tue 12 Dec 2006 10:11 PM (UTC)
Message
Just a warning. It's saying that in certain locales, the last 2 digits of the year will be displayed instead of 4.

Zeno McDohl,
Owner of Bleached InuYasha Galaxy
http://www.biyg.org
[Go to top] top

Posted by Metsuro   USA  (389 posts)  [Biography] bio
Date Reply #2 on Tue 12 Dec 2006 10:28 PM (UTC)
Message
right but using smaugfuss 1.7 all warnings are treated as errors. And I'd like to get this cleaned up.

Everything turns around in the end
[Go to top] top

Posted by David Haley   USA  (3,881 posts)  [Biography] bio
Date Reply #3 on Tue 12 Dec 2006 10:31 PM (UTC)
Message
See man strftime section BUGS. That might help you, although it's for %c, not %x.

David Haley aka Ksilyan
Head Programmer,
Legends of the Darkstone

http://david.the-haleys.org
[Go to top] top

Posted by Metsuro   USA  (389 posts)  [Biography] bio
Date Reply #4 on Tue 12 Dec 2006 10:32 PM (UTC)

Amended on Tue 12 Dec 2006 10:34 PM (UTC) by Metsuro

Message
I didn't actually write that part, I just use it heh.
char * current_date( )
{
    static char buf [ 128 ];
    struct tm * datetime;

    datetime = localtime( &current_time );
    strftime( buf, 128, "%x", datetime );
    return buf;
}

It just is suppose to get the current date, not the time, so It can be used to display in the change.

Everything turns around in the end
[Go to top] top

Posted by Zeno   USA  (2,871 posts)  [Biography] bio
Date Reply #5 on Tue 12 Dec 2006 11:09 PM (UTC)
Message
You should be able to change it so that warnings will still compile. Check the Makefile.

Zeno McDohl,
Owner of Bleached InuYasha Galaxy
http://www.biyg.org
[Go to top] top

Posted by David Haley   USA  (3,881 posts)  [Biography] bio
Date Reply #6 on Tue 12 Dec 2006 11:21 PM (UTC)
Message
Did you try the workaround proposed in man strftime?

David Haley aka Ksilyan
Head Programmer,
Legends of the Darkstone

http://david.the-haleys.org
[Go to top] top

Posted by Metsuro   USA  (389 posts)  [Biography] bio
Date Reply #7 on Tue 12 Dec 2006 11:52 PM (UTC)
Message
I didn't see an bug section in the man. all I saw was all the options and such. And I'd rather not just leave it, I like trying to be neat as possible.

Everything turns around in the end
[Go to top] top

Posted by Zeno   USA  (2,871 posts)  [Biography] bio
Date Reply #8 on Wed 13 Dec 2006 12:13 AM (UTC)
Message
A little odd. Here's what I have:
char * current_date( ) 
{ 
    static char buf [ 128 ];
    struct tm * datetime;

    datetime = localtime( &current_time );
    strftime( buf, sizeof( buf ), "%x", datetime );
    return buf;
}


Yet I don't get a compile warning.


Here's the bug section from the man page:
Quote:
BUGS
Some buggy versions of gcc complain about the use of %c: warning: '%c' yields only last 2 digits of year in
some locales. Of course programmers are encouraged to use %c, it gives the preferred date and time representa-
tion. One meets all kinds of strange obfuscations to circumvent this gcc problem. A relatively clean one is to
add an intermediate function
size_t my_strftime(char *s, size_t max, const char *fmt, const struct tm *tm) {
return strftime(s, max, fmt, tm);
}

Zeno McDohl,
Owner of Bleached InuYasha Galaxy
http://www.biyg.org
[Go to top] top

Posted by Metsuro   USA  (389 posts)  [Biography] bio
Date Reply #9 on Wed 13 Dec 2006 12:34 AM (UTC)
Message
Well I got around that problem it seems that my_strftime was already put in... but was never really ever used... but now I have this further on.

hometowns.c:326: initialization to `char *' from `const char *' discards qualifiers
I had a few more of these and I added const and it fixed it.

Everything turns around in the end
[Go to top] top

Posted by Metsuro   USA  (389 posts)  [Biography] bio
Date Reply #10 on Wed 13 Dec 2006 12:57 AM (UTC)
Message
OK nevermind I fixed that... but now.. I get this interesting mess...

o/track.o(.bss+0x0): In function `valid_edge(exit_data *)':
/usr/users/mud/aesdyn/Current/src/track.c:46: multiple definition of `hometown_list'
o/imc.o(.bss+0x131a0):/usr/users/mud/aesdyn/Current/src/imc.c:6819: first defined here
o/track.o(.bss+0x40): In function `bfs_enqueue(room_index_data *, char)':
/usr/users/mud/aesdyn/Current/src/track.c:61: multiple definition of `nation_list'
o/imc.o(.bss+0x131e0):/usr/users/mud/aesdyn/Current/src/imc.c:6823: first defined here
o/update.o(.bss+0x20): In function `neighbor_data type_info function':
/usr/users/mud/aesdyn/Current/src/update.c: multiple definition of `hometown_list'
o/imc.o(.bss+0x131a0):/usr/users/mud/aesdyn/Current/src/imc.c:6819: first defined here
o/update.o(.bss+0x60): In function `neighbor_data type_info function':
/usr/users/mud/aesdyn/Current/src/update.c: multiple definition of `nation_list'
o/imc.o(.bss+0x131e0):/usr/users/mud/aesdyn/Current/src/imc.c:6823: first defined here
collect2: ld returned 1 exit status


this is the end of the list, but... I have no idea what this all means.

Everything turns around in the end
[Go to top] top

Posted by David Haley   USA  (3,881 posts)  [Biography] bio
Date Reply #11 on Wed 13 Dec 2006 01:35 AM (UTC)
Message
You are probably defining those in a .h file, without externing them. If you put, say, int foo; into a .h file and include it in several .c files, you will get that error. The solution is to put extern int foo; in the .h, and int foo; in one and only one C file.

David Haley aka Ksilyan
Head Programmer,
Legends of the Darkstone

http://david.the-haleys.org
[Go to top] top

Posted by Metsuro   USA  (389 posts)  [Biography] bio
Date Reply #12 on Wed 13 Dec 2006 02:33 AM (UTC)
Message
Well that cut the list down to like... half...

Everything turns around in the end
[Go to top] top

Posted by Metsuro   USA  (389 posts)  [Biography] bio
Date Reply #13 on Wed 13 Dec 2006 02:35 AM (UTC)
Message
Uh, nevermind... I got it... thanks!

Everything turns around in the end
[Go to top] top

Posted by Metsuro   USA  (389 posts)  [Biography] bio
Date Reply #14 on Wed 13 Dec 2006 07:59 AM (UTC)
Message
Not... exactly the same problem but I still dont know what exactly this means... or how to fix it.

act_info.c:5498: warning: 'lcost' might be used uninitialized in this function


Everything turns around in the end
[Go to top] top

The dates and times for posts above are shown in Universal Co-ordinated Time (UTC).

To show them in your local time you can join the forum, and then set the 'time correction' field in your profile to the number of hours difference between your location and UTC time.


51,032 views.

This is page 1, subject is 2 pages long: 1 2  [Next page]

It is now over 60 days since the last post. This thread is closed.     [Refresh] Refresh page

Go to topic:           Search the forum


[Go to top] top

Quick links: MUSHclient. MUSHclient help. Forum shortcuts. Posting templates. Lua modules. Lua documentation.

Information and images on this site are licensed under the Creative Commons Attribution 3.0 Australia License unless stated otherwise.

[Home]


Written by Nick Gammon - 5K   profile for Nick Gammon on Stack Exchange, a network of free, community-driven Q&A sites   Marriage equality

Comments to: Gammon Software support
[RH click to get RSS URL] Forum RSS feed ( https://gammon.com.au/rss/forum.xml )

[Best viewed with any browser - 2K]    [Hosted at HostDash]