Project

General

Profile

WString::arg(long long) portability problem

Added by Saif Rehman almost 6 years ago

Since Wt 4, I've noticed Wt has been using typedef'd types for integer types: (u)int64_t, (u)int32_t and so on. However Wt::Dbo still uses long long as the default surrogate id.

Now the problem is that in GCC (x64) int64_t is defined as long int whereas in MSVC (x64) int64_t is defined as long long int. If I use the functions WString::arg(Dbo::ptr::id()) or WLocale::toString(Dbo::ptr::id()) on GCC it fails to compile because WString::arg(long long) doesn't exist. If I create an explicit definition for WString::arg(long long) then it fails to compile on MSVC (reporting that the definition already exists).

Now I don't know the reasoning behind the decision to use typedef'd overloads, but here is my suggestion to fix this problem:

-Define all such overloaded functions using C types rather than typedef'd types (in my opinion the best solution :))

What do you people think? Should I create an issue?


Replies (6)

RE: WString::arg(long long) portability problem - Added by lm at almost 6 years ago

(I am in no way affiliated with redmine, emweb, or WT except as an enthusiastic user.)

Don't bother creating an "Issue", create a pull request. Thanks for finding this!

If I use the functions WString::arg(Dbo::ptr::id()) or WLocale::toString(Dbo::ptr::id()) on GCC it fails to compile because WString::arg(long long) doesn't exist.

Hmm, I've compiled on GCC for sure, but I guess I haven't used this function. I don't generally use Wt::WString except when I need to interact with the library with one.

RE: WString::arg(long long) portability problem - Added by Saif Rehman almost 6 years ago

Yeah I could make a pull request too, it seems pretty simple. But first I'd like to hear one of Wt developer's opinion since they know their code best :)

RE: WString::arg(long long) portability problem - Added by Roel Standaert almost 6 years ago

This hasn't really changed in Wt 4. It's always been that way: there was arg(int), arg(unsigned), arg(int64_t) and arg(uint64_t). It seems sensible to me, though, that it would be (signed or unsigned) int, long and long long, if the idea is to have a generic interface.

RE: WString::arg(long long) portability problem - Added by Saif Rehman almost 6 years ago

So I should go ahead with making the pull request?

RE: WString::arg(long long) portability problem - Added by Roel Standaert almost 6 years ago

I just pushed some changes, so I might not need a pull request. It would be helpful if you could verify that they are to your liking, though.

Regards,

Roel

RE: WString::arg(long long) portability problem - Added by Saif Rehman almost 6 years ago

Yup, looks perfect. Thanks Roel.

    (1-6/6)