macros

c variadic functions confusion

最后都变了- 提交于 2021-02-08 07:10:25
问题 I'm trying to figure out what's behind va_start(), va_arg() macroses. The code below works well. #include <iostream> #include <cstdarg> void f(double a, double b, ...) { va_list arg; va_start(arg, b); double d; while((d = va_arg(arg, double)) != 0) { std::cout << d << '\n'; } } int main(int argc, char *argv[]) { f(1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0, 9.0, 0.0); return 0; } As I was expected it gave such output: 3 4 5 6 7 8 9. Then I found definitions of that macroses (in internet, cause my

c variadic functions confusion

旧巷老猫 提交于 2021-02-08 07:07:03
问题 I'm trying to figure out what's behind va_start(), va_arg() macroses. The code below works well. #include <iostream> #include <cstdarg> void f(double a, double b, ...) { va_list arg; va_start(arg, b); double d; while((d = va_arg(arg, double)) != 0) { std::cout << d << '\n'; } } int main(int argc, char *argv[]) { f(1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0, 9.0, 0.0); return 0; } As I was expected it gave such output: 3 4 5 6 7 8 9. Then I found definitions of that macroses (in internet, cause my

Report warning when apply container_of macro to embedded char array

假如想象 提交于 2021-02-08 05:39:38
问题 When I apply container_of macro to a C struct which contains an array of char, I got warning: initialization from incompatible pointer type . Here is the codes: #define container_of(ptr, type, member) ({ \ const typeof( ((type *)0)->member ) *__mptr = (ptr); \ (type *)( (char *)__mptr - offsetof(type,member) );}) struct st { int a; char b; char c[16]; void *p; }; int main(void) { struct st t = { .a = 101, .b = 'B', .c = "hello", .p = NULL }; char (*p)[16] = &t.c; struct st *s = container_of(p

Use different GoogleService-Info.plist for single project in xcode using swift4

房东的猫 提交于 2021-02-08 04:56:23
问题 I have a single project but with 4 different environments (Dev,Stagging,QA,Production). I have given their (environment's webservice url) paths from mobile's setting. Now I want to use different GoogleService-info.plist for all these different environments. Like when I select Dev from backend the project should take GoogleService-Info.plist of Dev project only. These GoogleService-Info.plists are created on 4 different accounts. Project should take the path of GoogleService-info.plist

Use different GoogleService-Info.plist for single project in xcode using swift4

痞子三分冷 提交于 2021-02-08 04:55:57
问题 I have a single project but with 4 different environments (Dev,Stagging,QA,Production). I have given their (environment's webservice url) paths from mobile's setting. Now I want to use different GoogleService-info.plist for all these different environments. Like when I select Dev from backend the project should take GoogleService-Info.plist of Dev project only. These GoogleService-Info.plists are created on 4 different accounts. Project should take the path of GoogleService-info.plist

Use different GoogleService-Info.plist for single project in xcode using swift4

*爱你&永不变心* 提交于 2021-02-08 04:55:34
问题 I have a single project but with 4 different environments (Dev,Stagging,QA,Production). I have given their (environment's webservice url) paths from mobile's setting. Now I want to use different GoogleService-info.plist for all these different environments. Like when I select Dev from backend the project should take GoogleService-Info.plist of Dev project only. These GoogleService-Info.plists are created on 4 different accounts. Project should take the path of GoogleService-info.plist

BOOST_PP expand sequence in the empty sequence case

我怕爱的太早我们不能终老 提交于 2021-02-08 02:58:30
问题 Using BOOST_PP I can expand a macro into multiple comma separated values with an additional token, as can be seen in the below code. However, it doesn't work in the no-argument case. #define BOOST_PP_VARIADICS #include <boost/preprocessor/punctuation/comma_if.hpp> #include <boost/preprocessor/seq/for_each_i.hpp> #include <boost/preprocessor/variadic/to_seq.hpp> #define ADD_TOKEN(r, token, i, e) \ BOOST_PP_COMMA_IF(i) token(e) #define WRAP(...) \ BOOST_PP_SEQ_FOR_EACH_I(ADD_TOKEN, decltype,

BOOST_PP expand sequence in the empty sequence case

蹲街弑〆低调 提交于 2021-02-08 02:57:29
问题 Using BOOST_PP I can expand a macro into multiple comma separated values with an additional token, as can be seen in the below code. However, it doesn't work in the no-argument case. #define BOOST_PP_VARIADICS #include <boost/preprocessor/punctuation/comma_if.hpp> #include <boost/preprocessor/seq/for_each_i.hpp> #include <boost/preprocessor/variadic/to_seq.hpp> #define ADD_TOKEN(r, token, i, e) \ BOOST_PP_COMMA_IF(i) token(e) #define WRAP(...) \ BOOST_PP_SEQ_FOR_EACH_I(ADD_TOKEN, decltype,