Windows Phone で既存の C コードを使用しようとしています。そのために、従来の C コードを含む Windows phone ランタイム コンポーネント (C++) を作成し、マネージ WP8 アプリケーションでそれを参照しています。
ソリューションを構築する際に問題に直面しています。
「sample.c」のプリコンパイル済みヘッダー オプションを無効にしました。
サンプル.h
int getNumber();
sample.c
#include <stdio.h>
#include"sample.h"
int main()
{
printf("This is a native C program.\n");
return 0;
}
int getNumber()
{
return 2014; // Sample value to return
}
NativeComponentRoot.cpp
#include "pch.h"
#include "NativeComponentRoot.h"
#include "sample.h"
using namespace NativeComponentRoot;
using namespace Platform;
WindowsPhoneRuntimeComponent::WindowsPhoneRuntimeComponent()
{
}
NumberGenerator::NumberGenerator()
{
}
int NumberGenerator::GetMeANumber()
{
int number = getNumber(); // Trying to invoke the function in sample.c
return number;
}
問題
「C」(C++ ではない) lib/コードを Windows Phone ランタイムに統合し、それをマネージド プロジェクトで使用するための適切なウォークスルーが見つかりませんでした。