Use of base/basictypes.h versus stdint.h types

198 views
Skip to first unread message

Wez

unread,
Jul 20, 2012, 4:49:35 PM7/20/12
to chromi...@chromium.org
Dear Chromers,

A few of us recently noticed that we have a bunch of Chrome code using stdint.h types (int32_t, int16_t, etc) rather than the base/basictypes.h versions (int32, int16).  Sometimes the two types of type are mixed within a single code file.

Would we be right in assuming that uses of the _t versions are incorrect, and should really be switched to the base/basictypes.h versions?

Cheers,

Wez

Mike Reed

unread,
Jul 20, 2012, 4:51:21 PM7/20/12
to w...@chromium.org, chromi...@chromium.org
Alternatively, given stdint.h, why should we maintain a different set of types?
> --
> Chromium Developers mailing list: chromi...@chromium.org
> View archives, change email options, or unsubscribe:
> http://groups.google.com/a/chromium.org/group/chromium-dev

Wez

unread,
Jul 20, 2012, 4:53:07 PM7/20/12
to Mike Reed, chromi...@chromium.org
If I remember correctly, MSVS doesn't provide a stdint.h, or at least didn't used to?

Mike Reed

unread,
Jul 20, 2012, 4:55:04 PM7/20/12
to Wez, chromi...@chromium.org
Agreed. easy enough to include a dummy version for that platform.

Jeffrey Yasskin

unread,
Jul 20, 2012, 4:55:15 PM7/20/12
to w...@chromium.org, Mike Reed, chromi...@chromium.org
http://blogs.msdn.com/b/vcblog/archive/2011/09/12/10209291.aspx says,
"Note that VC10 and VC11 already have <stdint.h>." We just switched to
VC10, right?

Jonathan Dixon

unread,
Jul 20, 2012, 4:59:54 PM7/20/12
to re...@google.com, w...@chromium.org, chromi...@chromium.org
On 20 July 2012 13:51, Mike Reed <re...@google.com> wrote:
Alternatively, given stdint.h, why should we maintain a different set of types?


I was going to type "because our style guide tells us so". But now, it tells us to use <stdint.h>   :-)

(So http://www.chromium.org/developers/coding-style#TOC-Types should be updated too, if that's the decision)

Darin Fisher

unread,
Jul 20, 2012, 5:14:43 PM7/20/12
to joth+p...@google.com, re...@google.com, w...@chromium.org, chromi...@chromium.org
On Fri, Jul 20, 2012 at 1:59 PM, Jonathan Dixon <jo...@chromium.org> wrote:



On 20 July 2012 13:51, Mike Reed <re...@google.com> wrote:
Alternatively, given stdint.h, why should we maintain a different set of types?


I was going to type "because our style guide tells us so". But now, it tells us to use <stdint.h>   :-)

(So http://www.chromium.org/developers/coding-style#TOC-Types should be updated too, if that's the decision)


I think it makes sense to switch to <stdint.h> and eventually eliminate the redundant typedefs in basictypes.h.  If necessary, we can provide a version of stdint.h for older versions of MSVS.  A good starting point for this work would be to make it possible to include stdint.h and then modify basictypes.h to use that.

-Darin

Marc-Antoine Ruel

unread,
Jul 21, 2012, 9:35:32 AM7/21/12
to jyas...@chromium.org, w...@chromium.org, Mike Reed, chromi...@chromium.org
2012/7/20 Jeffrey Yasskin <jyas...@chromium.org>
http://blogs.msdn.com/b/vcblog/archive/2011/09/12/10209291.aspx says,
"Note that VC10 and VC11 already have <stdint.h>." We just switched to
VC10, right?

No, we still support devs on VS2008. "We" will eventually force them to upgrade but I don't know how many people are still on 2008.

M-A 

Mike Reed

unread,
Jul 21, 2012, 1:05:44 PM7/21/12
to Darin Fisher, joth+p...@google.com, w...@chromium.org, chromi...@chromium.org
Skia has exactly this for older VS in our builds:

skia/trunk/include/config/sk_stdint.h

We just include it as needed.

Wez

unread,
Jul 23, 2012, 7:13:22 AM7/23/12
to Mike Reed, Darin Fisher, joth+p...@google.com, chromi...@chromium.org
Thanks for pointing that out, Mike; I'd been trying to work out how we have so much code "polluted" with the stdint versions but that somehow builds on Windows; anything that pulls in any Skia header will pull in Skia's sk_stdint.h for Windows, of course.

To move Chrome to stdint.h from basictypes.h we can:
1.  Add a stdint.h for pre-VS2010.
2.  Modify basictypes.h to use stdint.h.
3.  Start working through Chrome migrating basictypes.h names to stdint.h names, and switching the includes where possible.
4.  Remove the basictypes.h names.

Any other suggestions/comments on this?

Jay Soffian

unread,
Jul 23, 2012, 9:21:50 AM7/23/12
to w...@chromium.org, Mike Reed, Darin Fisher, joth+p...@google.com, chromi...@chromium.org
There's actually quite a few copies of stdint.h sprinkled about the
tree. Here's others I found when I looked last month:

ppapi/generators/test_cgen/stdint.h
sdch/open-vcdiff/vsprojects/stdint.h
skia/config/win/stdint.h
third_party/ffmpeg/chromium/include/win/stdint.h
third_party/leveldatabase/src/port/win/stdint.h
third_party/libusb/src/msvc/stdint.h
third_party/WebKit/Source/JavaScriptCore/os-win32/stdint.h
third_party/yasm/source/config/win/stdint.h

I started to work on a patch[*] to clean this up but ended up using a
simpler work-around for my particular use case.

[*] https://chromiumcodereview.appspot.com/10535083/

j.

Wez

unread,
Jul 23, 2012, 10:12:38 AM7/23/12
to Jay Soffian, Mike Reed, Darin Fisher, joth+p...@google.com, chromi...@chromium.org

David Michael

unread,
Jul 23, 2012, 12:01:20 PM7/23/12
to w...@chromium.org, Jay Soffian, Mike Reed, Darin Fisher, joth+p...@google.com, chromi...@chromium.org
FWIW, ppapi uses stdint-style type names for its public API. Internally, we usually use the basictypes.h-style. So at least there's some reason for the inconsistency there.

But ultimately moving over to just stdint would make our lives a little easier.

On Mon, Jul 23, 2012 at 8:12 AM, Wez <w...@chromium.org> wrote:

Philipp Neubeck

unread,
Oct 22, 2012, 7:22:26 AM10/22/12
to chromi...@chromium.org
What, if any, is the decision on this?
The google style-guide tells us to use stdint.h and the chromium style-guide doesn't state anything explicitly. However, basictypes.h seems to be used much more often than stdint.h.

Mark Mentovai

unread,
Oct 22, 2012, 9:38:53 AM10/22/12
to pneu...@google.com, chromium-dev
Follow the principle of remaining consistent with code around you. Within Chrome, keep using "base/basictypes.h" and int16 until someone decides to do a cleanup project to convert the codebase to <stdint.h> and int16_t. See bug 138542, which nobody’s started working on yet.


Reply all
Reply to author
Forward
0 new messages