Loki-Astari / ThorsMongo

C++ MongoDB API and BSON/JSON Serialization library
GNU General Public License v3.0
316 stars 72 forks source link

Not compiling with Visual Studio 2022 #85

Closed PiootrK closed 3 months ago

PiootrK commented 3 months ago

First my congratulations on great design!

However I have problem compiling under Windows with latest Visual V++ (17.10.1). This is the error I am getting when compiling example0.cpp

ThorsSerializerUtil.h(567): warning C4003: not enough arguments for function-like macro invocation 'ThorsLogAndThrowAction'

And more of the same follow.

My macro game is weak and I was unable to find any solution. This is the exact command line I am using:

cl /std:c++latest /EHsc /D_WIN32 /D_MBCS example0.cpp

Any advice would be appreciated.

Loki-Astari commented 3 months ago

I assume you are using header only version?

Blog: http://lokiastari.com/ StackOverflow: http://stackoverflow.com/users/14065/loki-astari?tab=profile LinkedIn: https://www.linkedin.com/in/lokiastari Resume: https://goo.gl/MOjkOp

On Sat, Jun 8, 2024 at 8:27 AM PiootrK @.***> wrote:

First my congratulations on great design!

However I have problem compiling under Windows with latest Visual V++ (17.10.1). This is the error I am getting when compiling example0.cpp

ThorsSerializerUtil.h(567): warning C4003: not enough arguments for function-like macro invocation 'ThorsLogAndThrowAction'

And more of the same follow.

My macro game is weak and I was unable to find any solution. This is the exact command line I am using:

cl /std:c++latest /EHsc /D_WIN32 /D_MBCS example0.cpp

Any advice would be appreciated.

— Reply to this email directly, view it on GitHub https://github.com/Loki-Astari/ThorsSerializer/issues/85, or unsubscribe https://github.com/notifications/unsubscribe-auth/AAMTRX5AIZEDKXURZC4YNSLZGMPH3AVCNFSM6AAAAABJACIDRGVHI2DSMVQWIX3LMV43ASLTON2WKOZSGM2DCNZQGM3TQNI . You are receiving this because you are subscribed to this thread.Message ID: @.***>

PiootrK commented 3 months ago

I assume you are using header only version?

Yes

Loki-Astari commented 3 months ago

I don't have visual studio to test:

Can you try changing this line:

ThorsSerializerUtil.h (line 565)

ThorsLogAndThrowCritical("ThorsAnvil::Serialize", "tryGetSizeFromSerializeType", "BSON backward compatibility. See comments in function.");

Change to:

ThorsLogAndThrowCritical("ThorsAnvil::Serialize", "tryGetSizeFromSerializeType", "BSON backward compatibility. See comments in function." , "");

On Sat, Jun 8, 2024 at 8:36 AM PiootrK @.***> wrote:

I assume you are using header only version?

Yes

— Reply to this email directly, view it on GitHub https://github.com/Loki-Astari/ThorsSerializer/issues/85#issuecomment-2156079262, or unsubscribe https://github.com/notifications/unsubscribe-auth/AAMTRX6UC7WR5SYAWRDNCFLZGMQIXAVCNFSM6AAAAABJACIDRGVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMZDCNJWGA3TSMRWGI . You are receiving this because you commented.Message ID: @.***>

-- Blog: http://lokiastari.com/ StackOverflow: http://stackoverflow.com/users/14065/loki-astari?tab=profile LinkedIn: https://www.linkedin.com/in/lokiastari Resume: https://goo.gl/MOjkOp

PiootrK commented 3 months ago

I did, there was more error:

ThorsSerializerUtil.h(567): warning C4003: not enough arguments for function-like macro invocation 'ThorsLogAndThrowAction' ThorsSerializerUtil.h(565): error C2760: syntax error: ',' was unexpected here; expected ')' ThorsSerializerUtil.h(565): error C3878: syntax error: unexpected token ')' following 'simple_declaration' ThorsSerializerUtil.h(565): note: error recovery skipped: ')' ThorsSerializerUtil.source(15): warning C4003: not enough arguments for function-like macro invocation 'ThorsLogAndThrowAction' ThorsSerializerUtil.source(13): error C2059: syntax error: ')' ThorsSerializerUtil.source(31): warning C4003: not enough arguments for function-like macro invocation 'ThorsLogAndThrowAction' ThorsSerializerUtil.source(29): error C2059: syntax error: ')' ThorsSerializerUtil.source(49): warning C4003: not enough arguments for function-like macro invocation 'ThorsLogAndThrowAction' ThorsSerializerUtil.source(47): error C2059: syntax error: ')' ThorsSerializerUtil.source(55): warning C4003: not enough arguments for function-like macro invocation 'ThorsLogAndThrowAction' ThorsSerializerUtil.source(53): error C2059: syntax error: ')' ThorsSerializerUtil.source(61): warning C4003: not enough arguments for function-like macro invocation 'ThorsLogAndThrowAction' ThorsSerializerUtil.source(59): error C2059: syntax error: ')' ThorsSerializerUtil.source(70): warning C4003: not enough arguments for function-like macro invocation 'ThorsLogAndThrowAction' ThorsSerializerUtil.source(68): error C2059: syntax error: ')' ThorsSerializerUtil.source(87): warning C4003: not enough arguments for function-like macro invocation 'ThorsLogAndThrowAction' ThorsSerializerUtil.source(85): error C2059: syntax error: ')' ThorsSerializerUtil.source(93): warning C4003: not enough arguments for function-like macro invocation 'ThorsLogAndThrowAction' ThorsSerializerUtil.source(91): error C2059: syntax error: ')' ThorsSerializerUtil.source(99): warning C4003: not enough arguments for function-like macro invocation 'ThorsLogAndThrowAction' ThorsSerializerUtil.source(97): error C2059: syntax error: ')' ThorsSerializerUtil.source(105): warning C4003: not enough arguments for function-like macro invocation 'ThorsLogAndThrowAction' ThorsSerializerUtil.source(103): error C2059: syntax error: ')' ThorsSerializerUtil.source(114): warning C4003: not enough arguments for function-like macro invocation 'ThorsLogAndThrowAction' ThorsSerializerUtil.source(112): error C2059: syntax error: ')'

Loki-Astari commented 3 months ago

I will see if I can set up a windows VM tomorrow and replicate the error.

Martin

Blog: http://lokiastari.com/ StackOverflow: http://stackoverflow.com/users/14065/loki-astari?tab=profile LinkedIn: https://www.linkedin.com/in/lokiastari Resume: https://goo.gl/MOjkOp

On Sat, Jun 8, 2024 at 2:29 PM PiootrK @.***> wrote:

I did, there was more error:

ThorsSerializerUtil.h(567): warning C4003: not enough arguments for function-like macro invocation 'ThorsLogAndThrowAction' ThorsSerializerUtil.h(565): error C2760: syntax error: ',' was unexpected here; expected ')' ThorsSerializerUtil.h(565): error C3878: syntax error: unexpected token ')' following 'simple_declaration' ThorsSerializerUtil.h(565): note: error recovery skipped: ')' ThorsSerializerUtil.source(15): warning C4003: not enough arguments for function-like macro invocation 'ThorsLogAndThrowAction' ThorsSerializerUtil.source(13): error C2059: syntax error: ')' ThorsSerializerUtil.source(31): warning C4003: not enough arguments for function-like macro invocation 'ThorsLogAndThrowAction' ThorsSerializerUtil.source(29): error C2059: syntax error: ')' ThorsSerializerUtil.source(49): warning C4003: not enough arguments for function-like macro invocation 'ThorsLogAndThrowAction' ThorsSerializerUtil.source(47): error C2059: syntax error: ')' ThorsSerializerUtil.source(55): warning C4003: not enough arguments for function-like macro invocation 'ThorsLogAndThrowAction' ThorsSerializerUtil.source(53): error C2059: syntax error: ')' ThorsSerializerUtil.source(61): warning C4003: not enough arguments for function-like macro invocation 'ThorsLogAndThrowAction' ThorsSerializerUtil.source(59): error C2059: syntax error: ')' ThorsSerializerUtil.source(70): warning C4003: not enough arguments for function-like macro invocation 'ThorsLogAndThrowAction' ThorsSerializerUtil.source(68): error C2059: syntax error: ')' ThorsSerializerUtil.source(87): warning C4003: not enough arguments for function-like macro invocation 'ThorsLogAndThrowAction' ThorsSerializerUtil.source(85): error C2059: syntax error: ')' ThorsSerializerUtil.source(93): warning C4003: not enough arguments for function-like macro invocation 'ThorsLogAndThrowAction' ThorsSerializerUtil.source(91): error C2059: syntax error: ')' ThorsSerializerUtil.source(99): warning C4003: not enough arguments for function-like macro invocation 'ThorsLogAndThrowAction' ThorsSerializerUtil.source(97): error C2059: syntax error: ')' ThorsSerializerUtil.source(105): warning C4003: not enough arguments for function-like macro invocation 'ThorsLogAndThrowAction' ThorsSerializerUtil.source(103): error C2059: syntax error: ')' ThorsSerializerUtil.source(114): warning C4003: not enough arguments for function-like macro invocation 'ThorsLogAndThrowAction' ThorsSerializerUtil.source(112): error C2059: syntax error: ')'

— Reply to this email directly, view it on GitHub https://github.com/Loki-Astari/ThorsSerializer/issues/85#issuecomment-2156191296, or unsubscribe https://github.com/notifications/unsubscribe-auth/AAMTRX46MOWT6G3I6M4TYDTZGNZS5AVCNFSM6AAAAABJACIDRGVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMZDCNJWGE4TCMRZGY . You are receiving this because you commented.Message ID: @.***>

PiootrK commented 3 months ago

Thank you!

Loki-Astari commented 3 months ago

I have a temporary fix for you. I will look at doing a full test and release next weekend when I have some time.

In the file: ThorsLogging/ThorLogging.h

Modify the following lines:

143 #define ThorsLogAndThrowFatal(...) ThorsLogAndThrowAction(FATAL, ThorsAnvil::Logging::FatalException, VA_ARGS) 144 #define ThorsLogAndThrowCritical(...) ThorsLogAndThrowAction(ERROR, ThorsAnvil::Logging::CriticalException, VA_ARGS) 145 #define ThorsLogAndThrowLogical(...) ThorsLogAndThrowAction(WARNING, ThorsAnvil::Logging::LogicalException, VA_ARGS__) 146 #define ThorsLogAndThrow(...) ThorsLogAndThrowAction(2, std::runtime_error, VA_ARGS__)

Put a "", just before the __VA_ARGS__ Code should look like this:

143 #define ThorsLogAndThrowFatal(...) ThorsLogAndThrowAction(FATAL, ThorsAnvil::Logging::FatalException, "", VA_ARGS) 144 #define ThorsLogAndThrowCritical(...) ThorsLogAndThrowAction(ERROR, ThorsAnvil::Logging::CriticalException, "", VA_ARGS) 145 #define ThorsLogAndThrowLogical(...) ThorsLogAndThrowAction(WARNING, ThorsAnvil::Logging::LogicalException, "", VA_ARGS__) 146 #define ThorsLogAndThrow(...) ThorsLogAndThrowAction(2, std::runtime_error, "", VA_ARGS__)

Sorry about that. Never built it using Visual studio before.

On Sat, Jun 8, 2024 at 10:53 PM PiootrK @.***> wrote:

Thank you!

— Reply to this email directly, view it on GitHub https://github.com/Loki-Astari/ThorsSerializer/issues/85#issuecomment-2156334204, or unsubscribe https://github.com/notifications/unsubscribe-auth/AAMTRX5M43CF7JRNUQZDMMDZGPUVRAVCNFSM6AAAAABJACIDRGVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMZDCNJWGMZTIMRQGQ . You are receiving this because you commented.Message ID: @.***>

-- Blog: http://lokiastari.com/ StackOverflow: http://stackoverflow.com/users/14065/loki-astari?tab=profile LinkedIn: https://www.linkedin.com/in/lokiastari Resume: https://goo.gl/MOjkOp

Loki-Astari commented 3 months ago

OK. Have found an actual issue that I can't currently fix:

Have posted a question to SO to see if they can help. https://stackoverflow.com/questions/78605945/macro-expansion-of-va-args-bug-in-visual-studio

On Mon, Jun 10, 2024 at 5:57 PM Loki Astari @.***> wrote:

I have a temporary fix for you. I will look at doing a full test and release next weekend when I have some time.

In the file: ThorsLogging/ThorLogging.h

Modify the following lines:

143 #define ThorsLogAndThrowFatal(...) ThorsLogAndThrowAction(FATAL, ThorsAnvil::Logging::FatalException, VA_ARGS) 144 #define ThorsLogAndThrowCritical(...) ThorsLogAndThrowAction(ERROR, ThorsAnvil::Logging::CriticalException, VA_ARGS) 145 #define ThorsLogAndThrowLogical(...) ThorsLogAndThrowAction(WARNING, ThorsAnvil::Logging::LogicalException, VA_ARGS__) 146 #define ThorsLogAndThrow(...) ThorsLogAndThrowAction(2, std::runtime_error, VA_ARGS__)

Put a "", just before the __VA_ARGS__ Code should look like this:

143 #define ThorsLogAndThrowFatal(...) ThorsLogAndThrowAction(FATAL, ThorsAnvil::Logging::FatalException, "", VA_ARGS) 144 #define ThorsLogAndThrowCritical(...) ThorsLogAndThrowAction(ERROR, ThorsAnvil::Logging::CriticalException, "", VA_ARGS) 145 #define ThorsLogAndThrowLogical(...) ThorsLogAndThrowAction(WARNING, ThorsAnvil::Logging::LogicalException, "", VA_ARGS__) 146 #define ThorsLogAndThrow(...) ThorsLogAndThrowAction(2, std::runtime_error, "", VA_ARGS__)

Sorry about that. Never built it using Visual studio before.

On Sat, Jun 8, 2024 at 10:53 PM PiootrK @.***> wrote:

Thank you!

— Reply to this email directly, view it on GitHub https://github.com/Loki-Astari/ThorsSerializer/issues/85#issuecomment-2156334204, or unsubscribe https://github.com/notifications/unsubscribe-auth/AAMTRX5M43CF7JRNUQZDMMDZGPUVRAVCNFSM6AAAAABJACIDRGVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMZDCNJWGMZTIMRQGQ . You are receiving this because you commented.Message ID: @.***>

-- Blog: http://lokiastari.com/ StackOverflow: http://stackoverflow.com/users/14065/loki-astari?tab=profile LinkedIn: https://www.linkedin.com/in/lokiastari Resume: https://goo.gl/MOjkOp

-- Blog: http://lokiastari.com/ StackOverflow: http://stackoverflow.com/users/14065/loki-astari?tab=profile LinkedIn: https://www.linkedin.com/in/lokiastari Resume: https://goo.gl/MOjkOp

PiootrK commented 3 months ago

Wow, thank you for your help! I tried what comment on SO said and added /Zc:preprocessor to compiler options... and it compiles! You may want to add this to the documentation somewhere.

I appreciate all the effort you put into resolving this, big cheers!

Loki-Astari commented 3 months ago

OK. I stand corrected. SO is great.

I have fixed all the build issues on Visual Issues and have started a build. If it works there will be a new header only version created in a couple of hours (I'll check in the morning).

Just pull the new new header only version.

You will also need to compile with the flag: /Zc:preprocessor to make sure visual studio uses the correct pre-processor.

Hope that helps.

On Tue, Jun 11, 2024 at 12:56 AM PiootrK @.***> wrote:

Wow, thank you for your help! I tried what comment on SO said and added /Zc:preprocessor to compiler options... and it compiles! You may want to add this to the documentation somewhere.

I appreciate all the effort you put into resolving this, big cheers!

— Reply to this email directly, view it on GitHub https://github.com/Loki-Astari/ThorsSerializer/issues/85#issuecomment-2160044108, or unsubscribe https://github.com/notifications/unsubscribe-auth/AAMTRXYSU3CRBBVAL4YVNH3ZG2UTPAVCNFSM6AAAAABJACIDRGVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMZDCNRQGA2DIMJQHA . You are receiving this because you commented.Message ID: @.***>

-- Blog: http://lokiastari.com/ StackOverflow: http://stackoverflow.com/users/14065/loki-astari?tab=profile LinkedIn: https://www.linkedin.com/in/lokiastari Resume: https://goo.gl/MOjkOp