0

Visual Studio 2010でビルドしたいCソースコードがあります。これは、プロジェクトに正しく追加したと思われる2つのライブラリを参照しています。画像を参照してください。

私が理解しているように、Cとしてコンパイルするには、ソースファイルの名前をname.cに変更する必要があります。ソリューションをビルドすると、AssemblyInfo.cppで未定義の名前空間エラーが発生します。

これらのエラーを修正するにはどうすればよいですか?

プログラムで.OBJ、.LIB、および.MAKファイルも取得したことに注意してください。.MAKファイルを開くと、次のエラーが発生します。

編集:

プロジェクトをWin32コンソールプロジェクトとして再作成しました。ソリューションをコンパイルすると、次のエラーが発生します。

1>------ Build started: Project: SerialCommWin32, Configuration: Debug Win32 ------
1>  SerialCommWin32.cpp
1>c:\users\jgoddijn\documents\development\vanduijnen\serialcommwin32\serialcommwin32\asynch_1.h(44): error C2143: syntax error : missing ',' before '*'
1>c:\users\jgoddijn\documents\development\vanduijnen\serialcommwin32\serialcommwin32\asynch_1.h(73): error C2143: syntax error : missing ',' before '*'
1>c:\users\jgoddijn\documents\development\vanduijnen\serialcommwin32\serialcommwin32\serialcommwin32.cpp(272): error C2146: syntax error : missing ')' before identifier 'far'
1>c:\users\jgoddijn\documents\development\vanduijnen\serialcommwin32\serialcommwin32\serialcommwin32.cpp(272): error C2065: 'far' : undeclared identifier
1>c:\users\jgoddijn\documents\development\vanduijnen\serialcommwin32\serialcommwin32\serialcommwin32.cpp(272): warning C4197: 'volatile long' : top-level volatile in cast is ignored
1>c:\users\jgoddijn\documents\development\vanduijnen\serialcommwin32\serialcommwin32\serialcommwin32.cpp(272): error C2059: syntax error : ')'
1>c:\users\jgoddijn\documents\development\vanduijnen\serialcommwin32\serialcommwin32\serialcommwin32.cpp(272): error C2059: syntax error : ')'
1>c:\users\jgoddijn\documents\development\vanduijnen\serialcommwin32\serialcommwin32\serialcommwin32.cpp(447): error C2664: 'wrtst_a1' : cannot convert parameter 4 from 'uint *' to 'int *'
1>          Types pointed to are unrelated; conversion requires reinterpret_cast, C-style cast or function-style cast
1>c:\users\jgoddijn\documents\development\vanduijnen\serialcommwin32\serialcommwin32\serialcommwin32.cpp(454): error C2146: syntax error : missing ')' before identifier 'far'
1>c:\users\jgoddijn\documents\development\vanduijnen\serialcommwin32\serialcommwin32\serialcommwin32.cpp(454): error C2065: 'far' : undeclared identifier
1>c:\users\jgoddijn\documents\development\vanduijnen\serialcommwin32\serialcommwin32\serialcommwin32.cpp(454): warning C4197: 'volatile long' : top-level volatile in cast is ignored
1>c:\users\jgoddijn\documents\development\vanduijnen\serialcommwin32\serialcommwin32\serialcommwin32.cpp(454): error C2059: syntax error : ')'
1>c:\users\jgoddijn\documents\development\vanduijnen\serialcommwin32\serialcommwin32\serialcommwin32.cpp(454): error C2059: syntax error : ')'
1>c:\users\jgoddijn\documents\development\vanduijnen\serialcommwin32\serialcommwin32\serialcommwin32.cpp(464): error C2146: syntax error : missing ')' before identifier 'far'
1>c:\users\jgoddijn\documents\development\vanduijnen\serialcommwin32\serialcommwin32\serialcommwin32.cpp(464): error C2065: 'far' : undeclared identifier
1>c:\users\jgoddijn\documents\development\vanduijnen\serialcommwin32\serialcommwin32\serialcommwin32.cpp(464): warning C4197: 'volatile long' : top-level volatile in cast is ignored
1>c:\users\jgoddijn\documents\development\vanduijnen\serialcommwin32\serialcommwin32\serialcommwin32.cpp(464): error C2059: syntax error : ')'
1>c:\users\jgoddijn\documents\development\vanduijnen\serialcommwin32\serialcommwin32\serialcommwin32.cpp(464): error C2059: syntax error : ')'
1>c:\users\jgoddijn\documents\development\vanduijnen\serialcommwin32\serialcommwin32\serialcommwin32.cpp(464): error C2143: syntax error : missing ';' before '{'
1>c:\users\jgoddijn\documents\development\vanduijnen\serialcommwin32\serialcommwin32\serialcommwin32.cpp(491): error C2664: 'wrtst_a1' : cannot convert parameter 4 from 'uint *' to 'int *'
1>          Types pointed to are unrelated; conversion requires reinterpret_cast, C-style cast or function-style cast
1>c:\users\jgoddijn\documents\development\vanduijnen\serialcommwin32\serialcommwin32\serialcommwin32.cpp(498): error C2146: syntax error : missing ')' before identifier 'far'
1>c:\users\jgoddijn\documents\development\vanduijnen\serialcommwin32\serialcommwin32\serialcommwin32.cpp(498): error C2065: 'far' : undeclared identifier
1>c:\users\jgoddijn\documents\development\vanduijnen\serialcommwin32\serialcommwin32\serialcommwin32.cpp(498): warning C4197: 'volatile long' : top-level volatile in cast is ignored
1>c:\users\jgoddijn\documents\development\vanduijnen\serialcommwin32\serialcommwin32\serialcommwin32.cpp(498): error C2059: syntax error : ')'
1>c:\users\jgoddijn\documents\development\vanduijnen\serialcommwin32\serialcommwin32\serialcommwin32.cpp(498): error C2059: syntax error : ')'
1>c:\users\jgoddijn\documents\development\vanduijnen\serialcommwin32\serialcommwin32\serialcommwin32.cpp(508): error C2146: syntax error : missing ')' before identifier 'far'
1>c:\users\jgoddijn\documents\development\vanduijnen\serialcommwin32\serialcommwin32\serialcommwin32.cpp(508): error C2065: 'far' : undeclared identifier
1>c:\users\jgoddijn\documents\development\vanduijnen\serialcommwin32\serialcommwin32\serialcommwin32.cpp(508): warning C4197: 'volatile long' : top-level volatile in cast is ignored
1>c:\users\jgoddijn\documents\development\vanduijnen\serialcommwin32\serialcommwin32\serialcommwin32.cpp(508): error C2059: syntax error : ')'
1>c:\users\jgoddijn\documents\development\vanduijnen\serialcommwin32\serialcommwin32\serialcommwin32.cpp(508): error C2059: syntax error : ')'
1>c:\users\jgoddijn\documents\development\vanduijnen\serialcommwin32\serialcommwin32\serialcommwin32.cpp(508): error C2143: syntax error : missing ';' before '{'
1>c:\users\jgoddijn\documents\development\vanduijnen\serialcommwin32\serialcommwin32\serialcommwin32.cpp(532): warning C4309: '=' : truncation of constant value
1>c:\users\jgoddijn\documents\development\vanduijnen\serialcommwin32\serialcommwin32\serialcommwin32.cpp(546): warning C4309: '=' : truncation of constant value
1>c:\users\jgoddijn\documents\development\vanduijnen\serialcommwin32\serialcommwin32\serialcommwin32.cpp(585): warning C4309: '=' : truncation of constant value
1>c:\users\jgoddijn\documents\development\vanduijnen\serialcommwin32\serialcommwin32\serialcommwin32.cpp(710): warning C4309: '=' : truncation of constant value
1>c:\users\jgoddijn\documents\development\vanduijnen\serialcommwin32\serialcommwin32\serialcommwin32.cpp(728): warning C4309: '=' : truncation of constant value
1>c:\users\jgoddijn\documents\development\vanduijnen\serialcommwin32\serialcommwin32\serialcommwin32.cpp(746): warning C4309: '=' : truncation of constant value
1>c:\users\jgoddijn\documents\development\vanduijnen\serialcommwin32\serialcommwin32\serialcommwin32.cpp(765): warning C4309: '=' : truncation of constant value
1>c:\users\jgoddijn\documents\development\vanduijnen\serialcommwin32\serialcommwin32\serialcommwin32.cpp(779): error C2146: syntax error : missing ')' before identifier 'far'
1>c:\users\jgoddijn\documents\development\vanduijnen\serialcommwin32\serialcommwin32\serialcommwin32.cpp(779): error C2065: 'far' : undeclared identifier
1>c:\users\jgoddijn\documents\development\vanduijnen\serialcommwin32\serialcommwin32\serialcommwin32.cpp(779): warning C4197: 'volatile long' : top-level volatile in cast is ignored
1>c:\users\jgoddijn\documents\development\vanduijnen\serialcommwin32\serialcommwin32\serialcommwin32.cpp(779): error C2059: syntax error : ')'
1>c:\users\jgoddijn\documents\development\vanduijnen\serialcommwin32\serialcommwin32\serialcommwin32.cpp(779): error C2059: syntax error : ')'
1>c:\users\jgoddijn\documents\development\vanduijnen\serialcommwin32\serialcommwin32\serialcommwin32.cpp(782): error C2146: syntax error : missing ')' before identifier 'far'
1>c:\users\jgoddijn\documents\development\vanduijnen\serialcommwin32\serialcommwin32\serialcommwin32.cpp(782): error C2065: 'far' : undeclared identifier
1>c:\users\jgoddijn\documents\development\vanduijnen\serialcommwin32\serialcommwin32\serialcommwin32.cpp(782): warning C4197: 'volatile long' : top-level volatile in cast is ignored
1>c:\users\jgoddijn\documents\development\vanduijnen\serialcommwin32\serialcommwin32\serialcommwin32.cpp(782): error C2059: syntax error : ')'
1>c:\users\jgoddijn\documents\development\vanduijnen\serialcommwin32\serialcommwin32\serialcommwin32.cpp(782): error C2059: syntax error : ')'
1>c:\users\jgoddijn\documents\development\vanduijnen\serialcommwin32\serialcommwin32\serialcommwin32.cpp(946): warning C4309: '=' : truncation of constant value
1>c:\users\jgoddijn\documents\development\vanduijnen\serialcommwin32\serialcommwin32\serialcommwin32.cpp(1364): error C2664: 'rdst_a1' : cannot convert parameter 3 from 'uchar *' to 'char *'
1>          Types pointed to are unrelated; conversion requires reinterpret_cast, C-style cast or function-style cast
1>c:\users\jgoddijn\documents\development\vanduijnen\serialcommwin32\serialcommwin32\serialcommwin32.cpp(1393): error C2146: syntax error : missing ')' before identifier 'far'
1>c:\users\jgoddijn\documents\development\vanduijnen\serialcommwin32\serialcommwin32\serialcommwin32.cpp(1393): error C2065: 'far' : undeclared identifier
1>c:\users\jgoddijn\documents\development\vanduijnen\serialcommwin32\serialcommwin32\serialcommwin32.cpp(1393): warning C4197: 'volatile long' : top-level volatile in cast is ignored
1>c:\users\jgoddijn\documents\development\vanduijnen\serialcommwin32\serialcommwin32\serialcommwin32.cpp(1393): error C2059: syntax error : ')'
1>c:\users\jgoddijn\documents\development\vanduijnen\serialcommwin32\serialcommwin32\serialcommwin32.cpp(1393): error C2059: syntax error : ')'
1>c:\users\jgoddijn\documents\development\vanduijnen\serialcommwin32\serialcommwin32\serialcommwin32.cpp(1393): error C2143: syntax error : missing ';' before '{'
========== Build: 0 succeeded, 1 failed, 0 up-to-date, 0 skipped ==========
4

1 に答える 1

2

コンパイラはおそらくファイル拡張子を実際には気にしません。プロジェクトの設定を調べてからC/C++ -> Advanced -> Compile As、を選択できますC Code(ただし、有効なCコードは有効なC ++コードでもある必要があります)。

また、これAssemblyInfo.cppはC ++/CLIプロジェクト専用です。したがって、そのファイルを削除するか、ビルドから除外します。

プロジェクトをC++/ CLIプロジェクトとして作成したように見えるため、プロジェクト設定をさらに編集するか、(最良のソリューションIMO)プロジェクトファイルをネイティブC / C ++プロジェクト(Win32プロジェクトWin32コンソールなど)として再作成する必要があります。アプリケーション)。

于 2012-10-17T13:44:33.760 に答える