-
Notifications
You must be signed in to change notification settings - Fork 107
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
Do not include Boost.Log related headers when MQTT_USE_LOG is off #927
Conversation
…SE_LOG is off. Also add missing include for <deque> in retained_topic_map
Codecov Report
@@ Coverage Diff @@
## master #927 +/- ##
==========================================
- Coverage 83.08% 83.05% -0.03%
==========================================
Files 64 64
Lines 10357 10357
==========================================
- Hits 8605 8602 -3
- Misses 1752 1755 +3 |
Nevermind, seems like it took a moment for Codecov to load all results. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM. Please add comments.
include/mqtt/log.hpp
Outdated
@@ -24,12 +28,12 @@ | |||
#include <boost/preprocessor/cat.hpp> | |||
#include <boost/preprocessor/comparison/greater_equal.hpp> | |||
|
|||
#endif |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
#endif | |
#endif // defined(MQTT_USE_LOG) |
Please add comment. See https://github.com/redboltz/mqtt_cpp/wiki/Coding-Rules#dont-use-negative-comparison-with-else
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I am used to this being taken care of by an autoformatter, but I didn't see a .clang-format file. Is there a different formatter that you use?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I use my own emacs setting ;).
I tried to use clang-format and wrote my rule.
Here is it:
Language: Cpp
# Indent
IndentWidth: 4
AccessModifierOffset: -4
#IndentBraces: false
ConstructorInitializerIndentWidth: 4
ContinuationIndentWidth: 4
IndentAccessModifiers: false
IndentCaseBlocks: false
IndentCaseLabels: false
IndentExternBlock: NoIndent
AlignAfterOpenBracket: AlwaysBreak
AllowAllParametersOfDeclarationOnNextLine: true
IndentGotoLabels: false
IndentPPDirectives: None
IndentRequires: true
IndentWrappedFunctionNames: false
LambdaBodyIndentation: Signature
UseTab: Never
#namespace
#AfterNamespace: false
#SplitEmptyNamespace: false
CompactNamespaces: false
FixNamespaceComments: true
# Align
AlignAfterOpenBracket: BlockIndent
#AlignAfterOpenBracket: AlwaysBreak
AlignArrayOfStructures: Right
AlignConsecutiveAssignments: AcrossEmptyLinesAndComments
AlignConsecutiveBitFields: AcrossEmptyLinesAndComments
AlignConsecutiveDeclarations: AcrossEmptyLinesAndComments
AlignConsecutiveMacros: AcrossEmptyLinesAndComments
AlignEscapedNewlines: Left
AlignOperands: Align
AlignTrailingComments: true
PointerAlignment: Left
ReferenceAlignment: Left
# Break
AlwaysBreakBeforeMultilineStrings: true
AlwaysBreakTemplateDeclarations: Yes
PenaltyBreakTemplateDeclaration: 0
BinPackArguments: false
BinPackParameters: false
BreakBeforeBraces: Custom
BraceWrapping:
AfterCaseLabel: false
BeforeCatch: true
BeforeElse: true
BeforeLambdaBody: true
BeforeWhile: false
BreakBeforeBinaryOperators: None
BreakBeforeConceptDeclarations: true
BreakBeforeTernaryOperators: true
BreakConstructorInitializers: BeforeColon
BreakInheritanceList: AfterColon
BreakStringLiterals: false
AllowAllConstructorInitializersOnNextLine: true
PackConstructorInitializers: Never
# SingleLine
AllowShortBlocksOnASingleLine: Empty
AllowShortCaseLabelsOnASingleLine: false
AllowShortEnumsOnASingleLine: false
AllowShortFunctionsOnASingleLine: Empty
AllowShortIfStatementsOnASingleLine: Never
AllowShortLambdasOnASingleLine: None
AllowShortLoopsOnASingleLine: false
#SplitEmptyFunction: true
#SplitEmptyRecord: true
#Macro
#Space
Cpp11BracedListStyle: false
DerivePointerAlignment: true
SpaceAfterCStyleCast: false
SpaceAfterLogicalNot: false
SpaceAfterTemplateKeyword: true
SpaceAroundPointerQualifiers: Default
SpaceBeforeAssignmentOperators: true
SpaceBeforeCaseColon: false
SpaceBeforeCpp11BracedList: false
SpaceBeforeCtorInitializerColon: false
SpaceBeforeInheritanceColon: true
SpaceBeforeParens: ControlStatements
SpaceBeforeRangeBasedForLoopColon: true
SpaceBeforeSquareBrackets: false
SpaceInEmptyBlock: false
SpaceInEmptyParentheses: false
SpacesBeforeTrailingComments: 1
SpacesInAngles: Never
SpacesInCStyleCastParentheses: false
SpacesInConditionalStatement: false
SpacesInParentheses: false
SpacesInSquareBrackets: false
# Other
FixNamespaceComments: true
IncludeBlocks: Preserve
MaxEmptyLinesToKeep: 2
SortIncludes: CaseSensitive
SortUsingDeclarations: true
AlignAfterOpenBracket: BlockIndent
might be error. In order to use is, I build clang-format master branch from the source code.
However, it is not enough for me.
I want to format like as follows:
void foo(
int param1,
char param2,
double param3
) {
async_function(
arg1,
arg2,
[
capture1,
capture2 = std::move(outer),
capture3
]
() mutable -> std::size_t {
// body
++capture1;
}
);
}
As far as I studied, the current clang-format doesn't provide much customization point for lamnda expression (especially capture list).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The .clang-format
above is not used for mqtt_cpp. Just demonstrate what I tried.
Thank you for updating. |
What
Avoid including headers that are only needed when MQTT_USE_LOG is enabled.
Why
Reduce the compile times and avoid unexpected linkage with Boost.Log libraries (e.g. when Boost auto-link is enabled).
Background
I am happy that mqtt_cpp provides such log customization option. I used it to adapt spdlog. The code for it here as a reference for other users:
mqttCpp.h:
mqttCpp.cpp