Skip to content

Commit

Permalink
Added more types to datatype information script.
Browse files Browse the repository at this point in the history
  • Loading branch information
tdulcet committed Apr 14, 2024
1 parent b9a3d7d commit 442dda1
Show file tree
Hide file tree
Showing 3 changed files with 38 additions and 13 deletions.
15 changes: 15 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -27,3 +27,18 @@ jobs:
- name: ShellCheck
run: bash -c 'shopt -s globstar; shellcheck -o avoid-nullary-conditions,check-extra-masked-returns,check-set-e-suppressed,deprecate-which,quote-safe-variables,require-double-brackets -s bash **/*.sh'
continue-on-error: true

macOS:
name: macOS Datatype Information

runs-on: ${{ matrix.os }}
strategy:
matrix:
os: [macos-13, macos-14]
fail-fast: false
steps:
- uses: actions/checkout@v4
- name: Script
run: |
set -x
bash -e -o pipefail -- typeinfo.sh
2 changes: 1 addition & 1 deletion info.sh
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ if [[ $# -ne 0 ]]; then
fi

# Check if on Linux
if ! echo "$OSTYPE" | grep -iq "linux"; then
if ! echo "$OSTYPE" | grep -iq '^linux'; then
echo "Error: This script must be run on Linux." >&2
exit 1
fi
Expand Down
34 changes: 22 additions & 12 deletions typeinfo.sh
Original file line number Diff line number Diff line change
Expand Up @@ -12,12 +12,6 @@ if [[ $# -ne 0 ]]; then
exit 1
fi

# Check if on Linux
if ! echo "$OSTYPE" | grep -iq "linux"; then
echo "Error: This script must be run on Linux." >&2
exit 1
fi

if ! command -v g++ >/dev/null; then
echo "Error: This script requires the GNU C compiler" >&2
echo "On Ubuntu and Debian run: 'sudo apt-get update -y' and 'sudo apt-get install build-essential -y'" >&2
Expand Down Expand Up @@ -107,6 +101,14 @@ int main()
cout << "unsigned long:\t\t" << sizeof(unsigned long) << '\n';
cout << "long long:\t\t" << sizeof(long long) << '\n';
cout << "unsigned long long:\t" << sizeof(unsigned long long) << '\n';
cout << "int8_t:\t\t\t" << sizeof(int8_t) << '\n';
cout << "uint8_t:\t\t" << sizeof(uint8_t) << '\n';
cout << "int16_t:\t\t" << sizeof(int16_t) << '\n';
cout << "uint16_t:\t\t" << sizeof(uint16_t) << '\n';
cout << "int32_t:\t\t" << sizeof(int32_t) << '\n';
cout << "uint32_t:\t\t" << sizeof(uint32_t) << '\n';
cout << "int64_t:\t\t" << sizeof(int64_t) << '\n';
cout << "uint64_t:\t\t" << sizeof(uint64_t) << '\n';
cout << "__int16_t:\t\t" << sizeof(__int16_t) << '\n';
cout << "__uint16_t:\t\t" << sizeof(__uint16_t) << '\n';
cout << "__int32_t:\t\t" << sizeof(__int32_t) << '\n';
Expand Down Expand Up @@ -142,12 +144,20 @@ int main()
cout << "unsigned long:\t\t" << setw(width) << 0 << setw(width) << ULONG_MAX << '\n';
cout << "long long:\t\t" << setw(width) << LLONG_MIN << setw(width) << LLONG_MAX << '\n';
cout << "unsigned long long:\t" << setw(width) << 0 << setw(width) << ULLONG_MAX << '\n';
cout << "__int16_t :\t\t" << setw(width) << numeric_limits<__int16_t>::min() << setw(width) << numeric_limits<__int16_t>::max() << '\n';
cout << "__uint16_t :\t\t" << setw(width) << numeric_limits<__uint16_t>::min() << setw(width) << numeric_limits<__uint16_t>::max() << '\n';
cout << "__int32_t :\t\t" << setw(width) << numeric_limits<__int32_t>::min() << setw(width) << numeric_limits<__int32_t>::max() << '\n';
cout << "__uint32_t :\t\t" << setw(width) << numeric_limits<__uint32_t>::min() << setw(width) << numeric_limits<__uint32_t>::max() << '\n';
cout << "__int64_t :\t\t" << setw(width) << numeric_limits<__int64_t>::min() << setw(width) << numeric_limits<__int64_t>::max() << '\n';
cout << "__uint64_t :\t\t" << setw(width) << numeric_limits<__uint64_t>::min() << setw(width) << numeric_limits<__uint64_t>::max() << '\n';
cout << "int8_t:\t\t\t" << setw(width) << INT8_MIN << setw(width) << INT8_MAX << '\n';
cout << "uint8_t:\t\t" << setw(width) << 0 << setw(width) << UINT8_MAX << '\n';
cout << "int16_t:\t\t" << setw(width) << INT16_MIN << setw(width) << INT16_MAX << '\n';
cout << "uint16_t:\t\t" << setw(width) << 0 << setw(width) << UINT16_MAX << '\n';
cout << "int32_t:\t\t" << setw(width) << INT32_MIN << setw(width) << INT32_MAX << '\n';
cout << "uint32_t:\t\t" << setw(width) << 0 << setw(width) << UINT32_MAX << '\n';
cout << "int64_t:\t\t" << setw(width) << INT64_MIN << setw(width) << INT64_MAX << '\n';
cout << "uint64_t:\t\t" << setw(width) << 0 << setw(width) << UINT64_MAX << '\n';
cout << "__int16_t:\t\t" << setw(width) << numeric_limits<__int16_t>::min() << setw(width) << numeric_limits<__int16_t>::max() << '\n';
cout << "__uint16_t:\t\t" << setw(width) << numeric_limits<__uint16_t>::min() << setw(width) << numeric_limits<__uint16_t>::max() << '\n';
cout << "__int32_t:\t\t" << setw(width) << numeric_limits<__int32_t>::min() << setw(width) << numeric_limits<__int32_t>::max() << '\n';
cout << "__uint32_t:\t\t" << setw(width) << numeric_limits<__uint32_t>::min() << setw(width) << numeric_limits<__uint32_t>::max() << '\n';
cout << "__int64_t:\t\t" << setw(width) << numeric_limits<__int64_t>::min() << setw(width) << numeric_limits<__int64_t>::max() << '\n';
cout << "__uint64_t:\t\t" << setw(width) << numeric_limits<__uint64_t>::min() << setw(width) << numeric_limits<__uint64_t>::max() << '\n';
#ifdef __SIZEOF_INT128__
cout << "__int128_t:\t\t" << setw(width) << outputbase(numeric_limits<__int128_t>::min()) << setw(width) << outputbase(numeric_limits<__int128_t>::max()) << '\n';
cout << "__uint128_t:\t\t" << setw(width) << outputbase(numeric_limits<__uint128_t>::min()) << setw(width) << outputbase(numeric_limits<__uint128_t>::max()) << '\n';
Expand Down

0 comments on commit 442dda1

Please sign in to comment.