D8045: cannot compile C file 'serialcommands.c

2020-04-02 18:02发布

I am getting compiler error D8045. cannot compile C file 'serialcommands.c' with the /clr option.

This file is a C library that has been written to talk over a serial port to a TI processor. The task that I need to do is wrap this library with a CLR wrapper (there will be additional questions posted to stackoverflow concerning marshalling data back and forth if you want some more easy points from CLI questions.)

I just want to use this C library from my CLR wrapper. I went to Properties->Configuration Properties->C/C++->General->Compile with Common Language runtime support = No Common Language Runtime support

Is this the correct way to do this? Will I experience nasty weird bugs later or are other things that I need to do to use this?

标签: .net c++-cli clr
1条回答
Fickle 薄情
2楼-- · 2020-04-02 18:42

Yes. You need to compile any C objects without /CLR, since the clr only understands classes and objects.

You can still use them from your C++/CLI project, wrapped inside of your "ref class" objects. This is a normal way of wrapping a C api in .NET objects.

查看更多
登录 后发表回答