2017-02-22 4 views
-1

私は別のチームから継承したライブラリーを持っています。他のチームによって使用されているため、変更できません。そのライブラリには、処理を開始するmainメソッドがあります。目的c:ライブラリのmainメソッドを呼び出す方法は?

図書館のmain.cの int型のmain(int型のargc、char型* ARGV [])

マイアプリのmain.m

int main(int argc, char * argv[]) 

は、それが私のObjective Cのプロジェクトにメイン名前を変更し、持っていることは可能ですアプリの起動時に起動されたものですか?

C#では、私はこれを行うことができます:

private delegate void mainDelegate(int argc, string[] argv); 
public Delegate LoadFunction<T>(string dllPath, string functionName) 
{ 
    var hModule = LoadLibrary(dllPath); 
    if (hModule == IntPtr.Zero) 
    { 
     throw new Win32Exception(); 
    } 
    var functionAddress = GetProcAddress(hModule, functionName); 
    return Marshal.GetDelegateForFunctionPointer(functionAddress, typeof(T)); 
} 

// initialize with 
main = (mainDelegate)LoadFunction<mainDelegate>(AppFile, "main"); 

// call with 
main(0x0, null); 

ない場合、それは私のものと衝突することなく、特定のライブラリのmainメソッドを呼び出すことは可能ですか?

答えて

1

Apple docsによれば、「すべてのCベースのアプリケーションのエントリポイントはmain関数であり、iOSアプリケーションも違いはありません」

これからは、mainという機能が1つしかないことがわかります。

関連する問題