chipKIT32 / chipKIT-core

Downloadable chipKIT core for use with Arduino 1.6 - 1.8+ IDE, PlatformIO, and UECIDE
http://chipkit.net/
Apache License 2.0
59 stars 53 forks source link

Strange typedef in Deeprom.h? #306

Open JacobChrist opened 8 years ago

JacobChrist commented 8 years ago

Does anyone else find this typedef in Deeprom.h to be strange

typedef uint32_t BOOL;

Its especially strange to me be because stdint.h is included in this file before this typedef.

majenkotech commented 8 years ago

It's a typical Microchipism

On Tue, 22 Nov 2016 00:40 Jacob Christ, notifications@github.com wrote:

Does anyone else find this typedef in Deeprom.h to be strange

typedef uint32_t BOOL;

Its especially strange to me be because stdint.h is included in this file before this typedef.

— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub https://github.com/chipKIT32/chipKIT-core/issues/306, or mute the thread https://github.com/notifications/unsubscribe-auth/ADouHGh31MHed-vztNsWMkbzZ0hvqRNIks5rAjn2gaJpZM4K44Ax .

Matt Jenkins Majenko Technologies http://stores.ebay.co.uk/Majenko-Technologies

JacobChrist commented 8 years ago

Do you know if it serves any purpose other than upsetting my obsessive compulsive disorder to remove unnecessary code?

majenkotech commented 8 years ago

It does the same to me. Much Microchip code us littered with such idiotic typedefs.

JacobChrist commented 8 years ago

The whole thing blows up if you take it out... seems like a problem for another day.

JacobChrist commented 8 years ago

I see what's going on here.. Its been too long since I touch c/c++.. I was confusing the order of the type being defined and what is already defined. This is creating a BOOL type out of a uint32_t which comes from stdint.h. I was thinking it was the other way around. I am less concerned now but wonder if this is the best way to pick up the BOOL type?

majenkotech commented 8 years ago

It's A way, certainly. Since there is no such thing really as a bool in c (there is in c++) crazy things get invented. I hate all-caps type names. They are loathsome.

EmbeddedMan commented 8 years ago

Normally you'd just #include and get the 'bool' type, but for some reason Microchip wants to use types that are in all caps and are named non-standard things (like BYTE and WORD). I really hope that, in the future, they're able to convert their code over to just and

types, as that would make their code more compatible with the style the rest of the embedded world now uses. *Brian On Mon, Nov 21, 2016 at 7:13 PM, Majenko Technologies < notifications@github.com> wrote: > It's A way, certainly. Since there is no such thing really as a bool in c > (there is in c++) crazy things get invented. I hate all-caps type names. > They are loathsome. > > — > You are receiving this because you are subscribed to this thread. > Reply to this email directly, view it on GitHub > https://github.com/chipKIT32/chipKIT-core/issues/306#issuecomment-262118622, > or mute the thread > https://github.com/notifications/unsubscribe-auth/AAbeCKHcJMEsDZCKvYuR4K3ql7QTotvDks5rAkHOgaJpZM4K44Ax > .
EmbeddedMan commented 8 years ago

Jacob, if there is more to discuss here with regards to the strange typedef you found, please continue the discussion. Otherwise I think you can close this issue.

JacobChrist commented 8 years ago

This can probably be closed. But Matt brought up a good point. Should we use BOOL or bool? In spite of what is probably the more elegant code we should probably ask WWAD? What would Arduino Do for maximum compatibility.

On Nov 27, 2016 6:56 PM, "Brian Schmalz" notifications@github.com wrote:

Jacob, if there is more to discuss here with regards to the strange typedef you found, please continue the discussion. Otherwise I think you can close this issue.

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/chipKIT32/chipKIT-core/issues/306#issuecomment-263172641, or mute the thread https://github.com/notifications/unsubscribe-auth/AAMGa7_WfmLnL7XgwmIsD-VV6pShtTNyks5rCkLcgaJpZM4K44Ax .

majenkotech commented 6 years ago

WWAD? They'd use boolean - which is what Java uses (and be incompatible with everyone else in the community). bool is what we should be using. It's the standard, and programs like vim highlight it properly, which they don't with BOOL and boolean.

EmbeddedMan commented 6 years ago

Agreed. BOOL (as well as things like INT8) are Microchip special defines. We should be sticking the standards in stdint.h and stdbool.h.

*Brian

On Fri, Feb 16, 2018 at 9:06 AM, Majenko Technologies < notifications@github.com> wrote:

WWAD? They'd use boolean - which is what Java uses (and be incompatible with everyone else in the community). bool is what we should be using. It's the standard, and programs like vim highlight it properly, which they don't with BOOL and boolean.

— You are receiving this because you commented. Reply to this email directly, view it on GitHub https://github.com/chipKIT32/chipKIT-core/issues/306#issuecomment-366260299, or mute the thread https://github.com/notifications/unsubscribe-auth/AAbeCHymfO5L-VOeenZr8N6pZk6CZhZ4ks5tVZlugaJpZM4K44Ax .

majenkotech commented 6 years ago

Maybe we should set out a standard coding style document that all commits to the core must conform to? That would annoy Digilent ;)

Things like:

... etc ...

EmbeddedMan commented 6 years ago

Yes, these should be our standards, and we should do our best to enforce them on PRs. I don't believe it going back and re-writing existing code just for coding standards like this, but as we update things . . .

*Brian

On Fri, Feb 16, 2018 at 10:20 AM, Majenko Technologies < notifications@github.com> wrote:

Maybe we should set out a standard coding style document that all commits to the core must conform to? That would annoy Digilent ;)

Things like:

  • Only use stdint.h integers: int8_t, int16_t, int32_t, uint8_t, uint16_t, uint32_t
  • Only use stdbool.h's bool
  • Always use camelCase for variable and function names
  • Always use UpperWordCase for class, type and struct names

... etc ...

— You are receiving this because you commented. Reply to this email directly, view it on GitHub https://github.com/chipKIT32/chipKIT-core/issues/306#issuecomment-366282592, or mute the thread https://github.com/notifications/unsubscribe-auth/AAbeCFMaq_DxUdCu7j5NuD-aNuXl-ubFks5tVarLgaJpZM4K44Ax .

JacobChrist commented 6 years ago

These all sound fair. But we should probably have a define for boolean for compatibility if it doesn't already exist.

define boolean BOOL

Jacob

Jacob Christ ProLinear/PONTECH, Inc. +1 (909) 652-0670 Phone http://www.pontech.com

On Fri, Feb 16, 2018 at 8:40 AM, Brian Schmalz notifications@github.com wrote:

Yes, these should be our standards, and we should do our best to enforce them on PRs. I don't believe it going back and re-writing existing code just for coding standards like this, but as we update things . . .

*Brian

On Fri, Feb 16, 2018 at 10:20 AM, Majenko Technologies < notifications@github.com> wrote:

Maybe we should set out a standard coding style document that all commits to the core must conform to? That would annoy Digilent ;)

Things like:

  • Only use stdint.h integers: int8_t, int16_t, int32_t, uint8_t, uint16_t, uint32_t
  • Only use stdbool.h's bool
  • Always use camelCase for variable and function names
  • Always use UpperWordCase for class, type and struct names

... etc ...

— You are receiving this because you commented. Reply to this email directly, view it on GitHub https://github.com/chipKIT32/chipKIT-core/issues/306# issuecomment-366282592, or mute the thread https://github.com/notifications/unsubscribe- auth/AAbeCFMaq_DxUdCu7j5NuD-aNuXl-ubFks5tVarLgaJpZM4K44Ax

.

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/chipKIT32/chipKIT-core/issues/306#issuecomment-366288694, or mute the thread https://github.com/notifications/unsubscribe-auth/AAMGa7Y6mklnAOxlj4bTGURifs61NWpkks5tVa-TgaJpZM4K44Ax .

majenkotech commented 6 years ago

Boolean is in the core. Ardueenies use it all the time.

EmbeddedMan commented 6 years ago

So, @majenkotech and @JacobChrist , what's the best way to move forward with this issue so we can close it?

Should I do a wholesale replacement of BOOL in all core and libraries with bool?

JacobChrist commented 6 years ago

I think we should go for maximum compatibility with c standards without sacrificing Arduino compatibility. For this instance I think boil would get us closer to c standard libs w/o changing and Arduino compatibility, though not necessarily improving Arduino compatibility.

Jacob

On Sat, Mar 24, 2018, 11:08 AM Brian Schmalz notifications@github.com wrote:

So, @majenkotech https://github.com/majenkotech and @JacobChrist https://github.com/JacobChrist , what's the best way to move forward with this issue so we can close it?

Should I do a wholesale replacement of BOOL in all core and libraries with bool?

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/chipKIT32/chipKIT-core/issues/306#issuecomment-375913115, or mute the thread https://github.com/notifications/unsubscribe-auth/AAMGa_XfpLxQh6J-EZQ1rrNSaOPunJk7ks5thouHgaJpZM4K44Ax .