Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

broker: declare and define per module #2253

Merged
merged 2 commits into from May 17, 2020
Merged

broker: declare and define per module #2253

merged 2 commits into from May 17, 2020

Conversation

mcspr
Copy link
Collaborator

@mcspr mcspr commented May 17, 2020

We no longer need to specify each Broker type in broker.h
But, we exchange that bit for explicit initialization of the instance

Preserve existing syntax of ::Register & ::Publish so we don't have to change call sites, but only initialization code. I'd expect that we do something different in the future, delay breaking things until then.

Define helper macros to generate boilerplate code

  • namespace with Instance, type, Register(), Publish()
  • forward Register(...) -> Instance.Register(...),
    Publish(...) -> Instance.Publish(...)

re #2233

mcspr added 2 commits May 18, 2020 00:07
We no longer need to specify each Broker type in broker.h
But, we exchange that bit for explicit initialization of the instance

Define helper macros to generate boilerplate code
- namespace with Instance, Register(), Publish()
- forward Register(...) -> Instance.Register(...),
  Publish(...) -> Instance.Publish(...)
@mcspr mcspr merged commit 84b51cf into xoseperez:dev May 17, 2020
@mcspr mcspr deleted the broker/why branch May 17, 2020 23:29
@iprak
Copy link
Contributor

iprak commented May 18, 2020

I think maybe the header adjustment in this commit are causing these build errors?

c:\users\demo\.platformio\packages\toolchain-xtensa\xtensa-lx106-elf\include\c++\4.8.2\bits\stl_algobase.h:239:56: error: macro "min" passed 3 arguments, but takes just 2
Compiling .pio\build\nodemcu-lolin\src\i2c.cpp.o
     min(const _Tp& __a, const _Tp& __b, _Compare __comp)
                                                        ^
c:\users\demo\.platformio\packages\toolchain-xtensa\xtensa-lx106-elf\include\c++\4.8.2\bits\stl_algobase.h:260:56: error: macro "max" passed 3 arguments, but takes just 2
     max(const _Tp& __a, const _Tp& __b, _Compare __comp)
                                                        ^
Compiling .pio\build\nodemcu-lolin\src\influxdb.cpp.o
In file included from espurna\config/all.h:24:0,
                 from espurna\espurna.h:24,
                 from espurna\gpio.h:13,
                 from espurna\gpio.cpp:9:
c:\users\demo\.platformio\packages\toolchain-xtensa\xtensa-lx106-elf\include\c++\4.8.2\bits\stl_algobase.h:193:5: error: expected unqualified-id before 'const'
     min(const _Tp& __a, const _Tp& __b)
     ^
c:\users\demo\.platformio\packages\toolchain-xtensa\xtensa-lx106-elf\include\c++\4.8.2\bits\stl_algobase.h:193:5: error: expected ')' before 'const'
c:\users\demo\.platformio\packages\toolchain-xtensa\xtensa-lx106-elf\include\c++\4.8.2\bits\stl_algobase.h:193:5: error: expected ')' before 'const'
c:\users\demo\.platformio\packages\toolchain-xtensa\xtensa-lx106-elf\include\c++\4.8.2\bits\stl_algobase.h:193:5: error: expected initializer before 'const'
c:\users\demo\.platformio\packages\toolchain-xtensa\xtensa-lx106-elf\include\c++\4.8.2\bits\stl_algobase.h:216:5: error: expected unqualified-id before 'const'
     max(const _Tp& __a, const _Tp& __b)

@mcspr
Copy link
Collaborator Author

mcspr commented May 18, 2020

Looks like it. Does this help?

diff --git a/code/espurna/broker.h b/code/espurna/broker.h
index 8fd9361c..bc34dc2d 100644
--- a/code/espurna/broker.h
+++ b/code/espurna/broker.h
@@ -8,6 +8,8 @@ Copyright (C) 2017-2019 by Xose Pérez <xose dot perez at gmail dot com>

 #pragma once

+#include "espurna.h"
+
 #include <functional>
 #include <utility>
 #include <vector>
diff --git a/code/espurna/espurna.h b/code/espurna/espurna.h
index 9fe0c8a2..89d2587c 100644
--- a/code/espurna/espurna.h
+++ b/code/espurna/espurna.h
@@ -24,9 +24,9 @@ along with this program.  If not, see <http://www.gnu.org/licenses/>.
 #include "config/all.h"

 #include "board.h"
-#include "broker.h"
 #include "debug.h"
 #include "compat.h"
+#include "broker.h"
 #include "wifi.h"
 #include "storage_eeprom.h"
 #include "gpio.h"

compat should be loaded before broker, min() and max() are macros with Core 2.3.0

@echauvet
Copy link
Contributor

Yes, it does.

@iprak
Copy link
Contributor

iprak commented May 19, 2020

yes, thank you

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants