ETLCPP / etl

Embedded Template Library
https://www.etlcpp.com
MIT License
2.05k stars 373 forks source link

Code change causes warning with armcc compiler #749

Closed CurtisAMU closed 10 months ago

CurtisAMU commented 10 months ago

https://github.com/ETLCPP/etl/blob/b38afd7fc98f50a00b207b184506049f05ab7120/include/etl/private/vector_base.h#L171

The extra semicolon causes a warning if ETL_DEBUG_COUNT is not defined:

..\..\..\Lib\ETL\include\etl/private/vector_base.h(171): warning:  #381-D: extra ";" ignored
      ETL_DECLARE_DEBUG_COUNT;   ///< Internal debugging.

We have a zero warning policy for our project, which treats this as an error. It would be okay for debugging to have a warning to ignore but preferably not on release builds.

jwellbelove commented 10 months ago

Does it warn with void;

jwellbelove commented 10 months ago

Forget that last suggestion

jwellbelove commented 10 months ago

What about void(0);

CurtisAMU commented 10 months ago

ETL_DECLARE_DEBUG_COUNT; is a declaration and (void)0; does not work there; it's an expression. The former ETL_DECLARE_DEBUG_COUNT ///< Internal debugging. without the semicolon worked. What was the problem with that? It looks odd without the semicolon but should work.

This also works with armcc: #define ETL_DECLARE_DEBUG_COUNT struct SDebugCountDummy {}

CurtisAMU commented 10 months ago

A dummy typedef would also do.

jwellbelove commented 10 months ago

I added the semicolons as my IDE would not format following statements correctly without them. Everything would be indented.

jwellbelove commented 10 months ago

There will also be this warning if ETL_NO_CHECKS is defined for ETL_ASSERT etc.

jwellbelove commented 10 months ago

Do the other macros cause a warning? ETL_INCREMENT_DEBUG_COUNT etc

CurtisAMU commented 10 months ago

There will also be this warning if ETL_NO_CHECKS is defined for ETL_ASSERT etc.

Actually no. Empty statements are okay, it seems.

CurtisAMU commented 10 months ago

Do the other macros cause a warning? ETL_INCREMENT_DEBUG_COUNT etc

Not as far as I can see.

CurtisAMU commented 10 months ago

They are not used in a class declaration.

jwellbelove commented 10 months ago

If I try an empty statement in a Keil project using ARM compiler V6 I get

warning: empty expression statement has no effect; remove unnecessary ';' to silence this warning [-Wextra-semi-stmt]

CurtisAMU commented 10 months ago

One of those complementary differences between compiler V5 and V6. There, (void)0; would help in both cases, I'd expect.

jwellbelove commented 10 months ago

Can you try this for me? (It says it accepts zip files, but it doesn't) debug_count.h.txt

jwellbelove commented 10 months ago

Ignore that file, there's an error.

jwellbelove commented 10 months ago

Can you try this patch? 749-9465468-Removed semicolon warnings.patch

CurtisAMU commented 10 months ago

Looks good, the warning is gone.

jwellbelove commented 10 months ago

Fixed 20.38.1