microsoft / WinObjC

Objective-C for Windows
MIT License
6.24k stars 808 forks source link

Why is it necessary to disable precompiled header and add _WOC_APP for CPP fies? #288

Open Neil-Wan opened 8 years ago

Neil-Wan commented 8 years ago

In the *Add .cpp and use cx/Windows APIs** section of the document, it mentioned the below settings. What's the exact reason for this settings? My project is generated using vsimporter and I added the pch.cpp and pch.h precompiled headers. When adding c++/cx files, I omitted step 3 and 4 and it seems to work fine. Is it safe to omit them since adding that for every file is pretty annoy?

Right click the *.cpp and choose Properties and set the pages:

  1. Item Type: C/C++ compiler
  2. Code Generation->Runtime Library: Multi-threaded Debug DLL (/MDd)
  3. Precompiled Headers-> Precompiled Header: Not Using Precompiled Headers
  4. Command Line -> Additional Options: "$(AdditionalOptions) -D_WOC_APP"
cloudmonkeypeng commented 8 years ago

This is come from my suggestion. Because my project need all of them. My case is using the cx files to call winmd, how about yours?

Neil-Wan commented 8 years ago

What problems did you encounter when these are not added? My case is exposing a C style function for Objective-C to call WinRT API like below:

    void setupApplication()
    {
        auto appView = Windows::UI::ViewManagement::ApplicationView::GetForCurrentView();
        auto titleBar = appView->TitleBar;
        titleBar->BackgroundColor = Colors::White;
    }