regarding to conflict cap'n header file with windows header

30 views
Skip to first unread message

김동인

unread,
Jun 14, 2020, 11:53:34 AM6/14/20
to Cap'n Proto
hi. 

now. i am in difficulty situation that some of header files conflicting.

i haven't soloved this problem.

let me show my example code inorder to make you understand my situation T.T'

------------------ example code ------------------

#include <iostream>
#include <ws2tcpip.h>
#include <mswsock.h>

#include "test-my.capnp.h"
#include <capnp/message.h>
#include <capnp/serialize-packed.h>

int main()
{
    ::capnp::MallocMessageBuilder message;

    TestMy::Builder testBuilder = message.initRoot<TestMy>();
}

------------------------------------------------------

ws2tcpip.h and mswsock.h that i use in my main project conflict with some of capn header files.

if cap'n header files are used before ws2tcpip.h and mswsock.h, (below)

------------------ example code ------------------
#include "test-my.capnp.h"
#include <capnp/message.h>
#include <capnp/serialize-packed.h>

#include <iostream>
#include <ws2tcpip.h>
#include <mswsock.h>

int main()
{
    ::capnp::MallocMessageBuilder message;

    TestMy::Builder testBuilder = message.initRoot<TestMy>();
}

------------------------------------------------------

the problem will be solved.

but i feel that's very uncomfortable to use...

besides now i can not use that like that codes

because.... i am using precomplied header file in my project.

so....it has became very complicated situation.

could you give me good solution?

T.T


Kenton Varda

unread,
Jun 14, 2020, 12:02:01 PM6/14/20
to 김동인, Cap'n Proto
Hi,

Try adding this after including windows headers, but before capnp headers:

#include <kj/windows-sanity.h>

This header tries to work around some of the garbage that Windows headers leave in the global namespace.

-Kenton

--
You received this message because you are subscribed to the Google Groups "Cap'n Proto" group.
To unsubscribe from this group and stop receiving emails from it, send an email to capnproto+...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/capnproto/6bf9c24b-30ad-4664-823f-443e7fa0b31ao%40googlegroups.com.

김동인

unread,
Jun 14, 2020, 12:11:21 PM6/14/20
to Cap'n Proto


2020년 6월 15일 월요일 오전 12시 53분 34초 UTC+9, 김동인 님의 말:
it doesn't solve. (below)

#include <iostream>
#include <ws2tcpip.h>
#include <mswsock.h>

#include <kj/windows-sanity.h>

#include "test-my.capnp.h"
#include <capnp/message.h>
#include <capnp/serialize-packed.h>


int main()
{
    //::capnp::MallocMessageBuilder message;

    //TestMy::Builder testBuilder = message.initRoot<TestMy>();
}

is it right that i mean?

Kenton Varda

unread,
Jun 14, 2020, 12:17:52 PM6/14/20
to 김동인, Cap'n Proto
Please tell us the error you are seeing.

-Kenton

--
You received this message because you are subscribed to the Google Groups "Cap'n Proto" group.
To unsubscribe from this group and stop receiving emails from it, send an email to capnproto+...@googlegroups.com.

김동인

unread,
Jun 14, 2020, 12:27:56 PM6/14/20
to Cap'n Proto
There are a punch of Error Messages

so. i  have attached source codes in my test project.

my environment is VS2019.

and this is some of error messages. thank you 

주석 2020-06-15 012305.png


TestCapnProto.zip

Kenton Varda

unread,
Jun 14, 2020, 6:48:51 PM6/14/20
to 김동인, Cap'n Proto
The first error is the one that matters. Usually all the rest are side-effects of the first one.

Sorry but I can't debug this for you. You'll need to dig in a little more and figure out which name conflict is causing the error. Usually, it's because the Windows headers have #defined a macro that collides with an enum or constant declaration in capnp.

BTW, I noticed your code doesn't include windows.h, but only some other windows headers. You should probably include windows.h too. It might be that kj/windows-sanity.h only works after windows.h has been included...

-Kenton

--
You received this message because you are subscribed to the Google Groups "Cap'n Proto" group.
To unsubscribe from this group and stop receiving emails from it, send an email to capnproto+...@googlegroups.com.
Reply all
Reply to author
Forward
0 new messages