Skip to content

docs: document the need for a 64-bit type and stdint.h#20384

Closed
dfandrich wants to merge 1 commit intomasterfrom
dfandrich/internals
Closed

docs: document the need for a 64-bit type and stdint.h#20384
dfandrich wants to merge 1 commit intomasterfrom
dfandrich/internals

Conversation

@dfandrich
Copy link
Contributor

These are requirements above and above C89.

Closes #20384

@dfandrich
Copy link
Contributor Author

There is still a HAVE_STDINT_H check though, so is this actually true? We're using all kinds of types like uint64_t nowadays, so they have to be defined and that's where they are supposed to be. In what condition is this not true?

machines. Most of libcurl assumes more or less POSIX compliance but that is
not a requirement.
not a requirement. The compiler must support a 64-bit integer type and supply
the stdint.h header file (which was not strictly required before C99).
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We check for the stdint.h file and can manage without it. I believe the OS400 build right now even needs it to be set not present.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Where are the fixed-size integer types defined then if not stdint.h? inttypes.h? So, does at least one of those files need to exist so those types are defined?

Copy link
Member

@vszakats vszakats Jan 21, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

inttypes.h isn't included. Existing pre-fills set HAVE_STDINT_H to 1. Patrick commented recently, that OS400 does provides this header (albeit without the optional uintptr_t). I guess config-os400.h does not set it because if set, formdata.h uses uintptr_h (since fe7703a), also curl_setup.h (since f4e2395). uintptr_t is also used in Rustls- and libbacktrace-conditional code.

curl required C99 types for H2, H3 and wolfSSL for a long time, without checking HAVE_STDINT_H, and without reports about it.

With wider use of 64-bit and non-64-bit C99 types, I'd guess stdint.h is a hard requirement now, and documenting it is useful IMO. Also the checks could maybe dropped to clarify. For uintptr_t we can use a fallback for OS400 (and other platforms, but so far there is no more we know about).

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I've reworded the text to make it less ambiguous and to mention inttypes.h as an option.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I wonder if we shall mention inttypes.h? Both are C99, and we already include stdint.h.
To support both, we'd need to do all the configure work, and in most cases include both.
This looks like a waste of cycles for every build.

(MSVC is one outlier that introduced stdint.h first (VS2010), then inttypes.h in VS2013.
That's one reason curl uses stdint.h.

dfandrich added a commit that referenced this pull request Jan 21, 2026
These are requirements above and above C89.

Closes #20384
@dfandrich dfandrich force-pushed the dfandrich/internals branch from 59bfe48 to e6c80e4 Compare January 21, 2026 09:33
@github-actions github-actions bot added the CI Continuous Integration label Jan 21, 2026
@testclutch
Copy link

Analysis of PR #20384 at e6c80e41:

Test 310 failed, which has NOT been flaky recently, so there could be a real issue in this PR. Note that this test has failed in 12 different CI jobs (the link just goes to one of them). Note that this CI job has had a number of other flaky tests recently (5, to be exact) so it may be that this failure is rather a systemic issue with this job and not with this specific PR.

Generated by Testclutch

dfandrich added a commit that referenced this pull request Jan 22, 2026
These are requirements above and above C89.

Closes #20384
@dfandrich dfandrich force-pushed the dfandrich/internals branch from e6c80e4 to 3c5aea9 Compare January 22, 2026 23:51
These are requirements above and above C89.

Closes #20384
@dfandrich dfandrich force-pushed the dfandrich/internals branch from 3c5aea9 to 81dd66f Compare January 23, 2026 00:00
@dfandrich
Copy link
Contributor Author

dfandrich commented Jan 23, 2026 via email

dfandrich added a commit that referenced this pull request Jan 23, 2026
curl now expects C99-style fixed-length types to be defined, and the
standard location for that is stdint.h. There is no need to check for a
header file that must exist.

Caveats:
- Some systems predating C99 defined the necessary types in inttypes.h,
  but this PR doesn't affect those.
- Apparently, OS400 doesn't define uintptr_t but does have stdint.h, so
  this PR will probably break it. The uintptr_t dependencies should
  probably be guarded by a new HAVE_UINTPTR_T macro (or maybe
  MISSING_UINTPTR_T) to use alternate code there.

Ref: #20384
@vszakats
Copy link
Member

My memory is that inttypes.h was used to hold typedefs on various systems before C99, and C99 standardized that type definitions go in stdint.h and printf specifiers go in inttypes.h. Back in 2001 I wrote some autoconf macros to detect the fixed-size types in both inttypes.h and stdint.h but prefer the stdint.h ones because they were standardized. I assumed that's what was happening in curl, too, but it seems like inttypes.h there is only used for Windows. In looking at the includes more now, it looks like the fixed-size types are expected to be found in stdint.h now. Can we drop the entire HAVE_STDINT_H dance now and expect it to be there? I actually thought that was what was being done. I'll create a PR and see what CI thinks about that.

It seems safe to drop, yes. I also prepared a patch a few days ago.

There is no more inttypes.h in curl though. (but there is in libssh2)
Due to no use both have been deleted in 60359ad.
Later HAVE_STDINT_H was readded, but with VS2008 gone, there
is no known system without it.

@dfandrich
Copy link
Contributor Author

dfandrich commented Jan 23, 2026 via email

Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR documents compiler requirements for curl/libcurl that extend beyond the C89 standard, specifically the need for 64-bit integer type support and C99-style fixed-width integer types from stdint.h or inttypes.h.

Changes:

  • Updated INTERNALS.md to document the requirement for 64-bit integer types and stdint.h/inttypes.h headers
  • Added related terms to the spell-checking dictionary

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated no comments.

File Description
docs/INTERNALS.md Added documentation clarifying that while curl targets C89 compilers, it requires support for 64-bit integers and C99-style fixed-width types from stdint.h or inttypes.h
.github/scripts/pyspelling.words Added "inttypes", "stdint", and "uint" to the spell-checking dictionary to support the documentation changes

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

vszakats added a commit that referenced this pull request Jan 28, 2026
curl requires `stdint.h` from C99, and no longer builds without it since
v8.18.0 (after dropping VS2008 support). Assume it's available, drop
feature checks.

Also:
- drop duplicate `stdint.h` includes.
- introduce internal `HAVE_UINTPTR_T`, enabled by default.
- OS400: disable `HAVE_UINTPTR_T`.
- build: keep cmake pre-fill and `cmp-config.pl` exception because cmake
  and autotools both detect `stdint.h` implicitly.

Co-authored-by: Dan Fandrich
Ref: #20405
Ref: #20384
Follow-up to 2e1a045 #17931

Closes #20406
@vszakats
Copy link
Member

I'd still reduce the text to stdint.h, which is what curl actually uses.

@dfandrich
Copy link
Contributor Author

Yes, thanks for making that part more consistent.

@dfandrich dfandrich closed this in 3509a41 Jan 28, 2026
@dfandrich dfandrich deleted the dfandrich/internals branch January 28, 2026 16:48
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

CI Continuous Integration documentation

Development

Successfully merging this pull request may close these issues.

5 participants