Skip to content

Commit

Permalink
Merge pull request #17 from mcci-catena/TMM-issue-ifdef
Browse files Browse the repository at this point in the history
Convert #if's on config variables to #if defined for consistency
  • Loading branch information
terrillmoore authored Jul 9, 2017
2 parents a39c1aa + 720725c commit 4546cff
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions src/lmic/lmic.c
Original file line number Diff line number Diff line change
Expand Up @@ -1094,9 +1094,9 @@ static int decodeBeacon (void) {
ASSERT(LMIC.dataLen == LEN_BCN); // implicit header RX guarantees this
xref2u1_t d = LMIC.frame;
if(
#if CFG_eu868
#if defined(CFG_eu868)
d[OFF_BCN_CRC1] != (u1_t)os_crc16(d,OFF_BCN_CRC1)
#elif CFG_us915
#elif defined(CFG_us915)
os_rlsbf2(&d[OFF_BCN_CRC1]) != os_crc16(d,OFF_BCN_CRC1)
#endif
)
Expand Down Expand Up @@ -2162,7 +2162,7 @@ static void processBeacon (xref2osjob_t osjob) {
LMIC.bcnRxtime = LMIC.bcninfo.txtime + BCN_INTV_osticks - calcRxWindow(0,DR_BCN);
LMIC.bcnRxsyms = LMIC.rxsyms;
rev:
#if CFG_us915
#if defined(CFG_us915)
LMIC.bcnChnl = (LMIC.bcnChnl+1) & 7;
#endif
#if !defined(DISABLE_PING)
Expand Down

2 comments on commit 4546cff

@vicatcu
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@terrillmoore is this a load-bearing change; that is to say does it materially affect the compilation outcome?

@terrillmoore
Copy link
Member Author

@terrillmoore terrillmoore commented on 4546cff May 15, 2019

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It only affects things if you have #define CFG_us915 0 as the flag to select "us915" mode. (The code was not consistent in using #if vs #ifdef. According to ISO C, #if {undefinedVar} is silently the same as #if 0. So if you #define CFG_us915 0 you'd get a half-configured codebase, with US915 code in some places, and nothing in others.)

This is why I avoid #ifdef as a config method, as opposed to #if... but the code uses #ifdef and that's not going to change right now.

Please sign in to comment.