-
February 22nd, 2015, 11:55 AM
#1
Trouble with C And Windows Runtime
I am a very experienced C programmer. I am getting into Windows 8.1 Store apps.
As we all know, when dealing with C on Visual Studio, the best best is to correctly name your source files as .c and not .cpp
The problem is that doing so in metro world gives lots of 'error D8048: cannot compile C file X with the /ZW option' errors. It is my understanding that I need this flag for the correct runtime.
I'd like to compile some legacy code with lots of malloc commands in, so renaming the files to .cpp is not practical unless I can turn off the resulting errors about casting from void*
Any idea how I can go about writing C for store apps?
-
February 23rd, 2015, 04:47 AM
#2
Re: Trouble with C And Windows Runtime
All advice is offered in good faith only. All my code is tested (unless stated explicitly otherwise) with the latest version of Microsoft Visual Studio (using the supported features of the latest standard) and is offered as examples only - not as production quality. I cannot offer advice regarding any other c/c++ compiler/IDE or incompatibilities with VS. You are ultimately responsible for the effects of your programs and the integrity of the machines they run on. Anything I post, code snippets, advice, etc is licensed as Public Domain https://creativecommons.org/publicdomain/zero/1.0/ and can be used without reference or acknowledgement. Also note that I only provide advice and guidance via the forums - and not via private messages!
C++23 Compiler: Microsoft VS2022 (17.6.5)
-
February 25th, 2015, 07:01 PM
#3
Re: Trouble with C And Windows Runtime
Following the links advice, I started encountering varied problems and errors in header files I was not personally including directly. Some regression has clearly taken place in MSVS.
For now, I am using awk scripts to butcher my c into cpp. It is a shame that cpp lacks many convenient features such as named structure element initialization. I am not prepared to write cpp, I will just have to stick to the common subset for the short term.
-
February 25th, 2015, 07:02 PM
#4
Re: Trouble with C And Windows Runtime
Thanks for the suggestion tho'. It was good to try.
-
February 26th, 2015, 04:20 AM
#5
Re: Trouble with C And Windows Runtime
cpp lacks many convenient features such as named structure element initialization
What can you do in c that you can't in c++?
All advice is offered in good faith only. All my code is tested (unless stated explicitly otherwise) with the latest version of Microsoft Visual Studio (using the supported features of the latest standard) and is offered as examples only - not as production quality. I cannot offer advice regarding any other c/c++ compiler/IDE or incompatibilities with VS. You are ultimately responsible for the effects of your programs and the integrity of the machines they run on. Anything I post, code snippets, advice, etc is licensed as Public Domain https://creativecommons.org/publicdomain/zero/1.0/ and can be used without reference or acknowledgement. Also note that I only provide advice and guidance via the forums - and not via private messages!
C++23 Compiler: Microsoft VS2022 (17.6.5)
-
February 26th, 2015, 04:27 AM
#6
-
February 28th, 2015, 05:22 PM
#7
Re: Trouble with C And Windows Runtime
Originally Posted by VictorN
Good question!
There are some very important thigs available in C++ (OOP for example) that are not available in C.
But vice versa?
If you aren't on board with c++ at this point, you'll likely never be.
-
May 13th, 2015, 03:24 PM
#8
Re: Trouble with C And Windows Runtime
The error message is exactly what it says it is - VC++ does not support C++/CX extensions - enabled with /ZW compiler switch - in files compiled as C (which kinda makes sense, since those extensions are object-oriented).
The reason why you're seeing this is that, by default, all files in a Metro C++ project are compiled with /ZW. Unfortunately, this also applies to .c files, even though it doesn't actually work for them. What you need is to disable the extensions selectively for those files. You can do so via right-click -> Properties on a file or a selection of files in Solution Explorer. In the Property Pages dialog, navigate to C/C++ -> General, and look for "Enable Windows Run Time Extensions".
Last edited by bestellen; September 15th, 2015 at 04:16 PM.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|