top | item 44818852

(no title)

pratyahava | 6 months ago

yep, i remember when i tried coding for some atmega, i was wondering "how big are int and uint?" and wanted the types names to always include the size like uint8. but also there is char type, which should become char8 which looks even more crazy.

discuss

order

kazinator|6 months ago

Would you want the main function to be:

  int32_t main(int32_t argc, char **argv)?
How about struct tm?

  struct tm {$
    int32_t tm_sec;    /* Seconds (0-60) */$
    int32_t tm_min;    /* Minutes (0-59) */$
    int32_t tm_hour;   /* Hours (0-23) */$
    int32_t tm_mday;   /* Day of the month (1-31) */$
    int32_t tm_mon;    /* Month (0-11) */$
    int32_t tm_year;   /* Year - 1900 */$
    int32_t tm_wday;   /* Day of the week (0-6, Sunday = 0) */$
    int32_t tm_yday;   /* Day in the year (0-365, 1 Jan = 0) */$
    int32_t tm_isdst;  /* Daylight saving time */$
  };
What for? Or do we "shrink wrap" every field to the smallest type? "uint8_t tm_hour"?

zozbot234|6 months ago

You'd define architecture-specific typedefs to deal with these cases in a portable way. The C standard already has types like int_fast8_t that are similar in principle.