1

I found a note in a Software Development Plan:

Use of declared types is encouraged. Use of processor dependent types such as char, int, and long is discouraged.

What is the point of this statement? Why is the use of declared types encouraged? An example of a declared type in this context would be BOOL instead of bool.

gsamaras
  • 71,951
  • 46
  • 188
  • 305
newb7777
  • 517
  • 5
  • 22
  • 3
    Possibly because data types like `int` can be of different sizes on different platforms. – J...S Sep 08 '17 at 05:46
  • You probably need to add more context to your OP, but my guess is it's talking about portability. If a type called `uint64_t` exists, and you need 64 bits of storage, then that type would be expected to guarantee 64 bits of storage, rather than running into a what @J...S described. Does the book *not* say anything about this? Is there not a justification for that statement somewhere? – code_dredd Sep 08 '17 at 05:52
  • I think this needs a lot more context. If you are writing binary file formats, explicit "declared" types would be better, but for general code, why would `BOOL` be better than `bool`? Changing the underlying type would not have any positive effects, IMO, and in C++ in particular, things like `std::vector` are going to have completely different implementations depending on whether `BOOL` is `bool` or `int`. – Ken Y-N Sep 08 '17 at 05:54
  • 1
    I often use "goto" statements for exception handling and state machines in C code; even though I am often informed that using "goto" is discouraged. Discouragement of the use of char, int and long types... thats a new one for me. Seems like a fringe concept. I can think of several situations where "processor dependent" types, such as int, are appropriate, even in cross architecture code. The OP statement seems somewhat frivolous to me, outside the scope of an academic notion. My experience is (in real-world code) char, int and long are not "discouraged" when used appropriately. – Mahonri Moriancumer Sep 08 '17 at 06:08
  • 1
    What is `Software Development Plan` ? – alinsoar Sep 08 '17 at 06:53
  • If you are using C `bool` already is a `#define`... – Bo Persson Sep 08 '17 at 12:18

1 Answers1

1

Data types like int, long, etc. have a size that is platform dependent. As a result one can discourage the usage of those types, for platform independence...

Read more in:

gsamaras
  • 71,951
  • 46
  • 188
  • 305