[Top][All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [avr-gcc-list] 24 bits (u)ints

From: David Brown
Subject: Re: [avr-gcc-list] 24 bits (u)ints
Date: Thu, 1 Dec 2016 10:51:24 +0100
User-agent: Mozilla/5.0 (X11; Linux x86_64; rv:24.0) Gecko/20100101 Thunderbird/24.2.0

On 30/11/16 23:08, Diogo Martins Silva wrote:
> Thanks, guys.
> I asked because I tried a code snippet, but was getting errors.
> I found later that the errors came from my IDE's code analysis, not the
> compiler. The code works fine.
> Thumbs up for the assembly examples!

Sometimes it helps to "cheat" a little for the benefit of the IDE.
IDE's code analysis and syntax highlighting is not always in sync with
the compiler, which may have newer standards support or extensions that
confuse the IDE.  I usually have an ECLIPSE symbol defined as part of
the project within Eclipse, but not in my makefile (I use external
makefiles, not the IDE's project management).  Then I could have:

#ifdef ECLIPE
// In the IDE
#define __attribute__(x)

// Old-style static assertion
#define STATIC_ASSERT_NAME_(line)       STATIC_ASSERT_NAME2_(line)
#define STATIC_ASSERT_NAME2_(line)      assertion_failed_at_line_##line
#define static_assert(claim, warning) \
        typedef struct { \
                char STATIC_ASSERT_NAME_(__COUNTER__) [(claim) ? 2 : -2]; \

// Fake 24-bit ints for IDE
typedef long int int24_t;
typedef unsigned long int uint24_t;

// In the compiler

#ifdef __cplusplus
// static_assert is standard in c++11
// C11 static_assertion
#define static_assert _Static_assert

typedef __int24 int24_t;
typedef __uint24 uint24_t;


reply via email to

[Prev in Thread] Current Thread [Next in Thread]