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 2797970
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 7 deletions.
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
22 changes: 16 additions & 6 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,6 +144,14 @@ 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 << "int8_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';
Expand Down

0 comments on commit 2797970

Please sign in to comment.