468,315 Members | 1,442 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 468,315 developers. It's quick & easy.

Compile .c extensions as a C98++ using Visual Studio

Right now I have C99 code in .c extensions.

I compile it in VSC++ and it complains about a lot of errors.
I change the extensions to .cpp and compile in VSC++ and it succeeds.
Is there a way to keep my extensions .c, but tell VSC++ (through an
project option) to compile as C++98 code (as if it had .cpp
extensions).

Thanks!
Mar 5 '08 #1
3 2048
>Is there a way to keep my extensions .c, but tell VSC++ (through an
>project option) to compile as C++98 code (as if it had .cpp
extensions).
Have a look at the /TC and /TP options.

Dave
Mar 5 '08 #2
On Mar 5, 3:40*pm, David Lowndes <Dav...@example.invalidwrote:
Is there a way to keep my extensions .c, but tell VSC++ (through an
project option) to compile as C++98 code (as if it had .cpp
extensions).

Have a look at the /TC and /TP options.

Dave
Opse sorry. I forgot to mention I seen the "Project Properties >
Configuration Properties C/C++ Advanced Compile As" which has
the options:

Compile as C++ (/TP)
Compile as C Code (/TC)

The project is defaulted to /TP (no matter if the extention is .c
or .cpp). Even with /TP set, if the file extentions are all .c it
wont compile. Renaming the files (inside the solution explorer)
without changing any of the project properties (from .c to .cpp) makes
it compile.

As a result it doesn't look like this setting does anything for me
(and the extention on the files are what's dictating compile type). I
was hoping for another property someplace (something like ignore file
extention) kinda thing; or another work-around; or maybe I'm just
using the "Compile As" incorrectly?

Thanks, NB
Mar 6 '08 #3
On Mar 5, 4:48 pm, NvrBst <nvr...@gmail.comwrote:
On Mar 5, 3:40 pm, David Lowndes <Dav...@example.invalidwrote:
>Is there a way to keep my extensions .c, but tell VSC++ (through an
>project option) to compile as C++98 code (as if it had .cpp
>extensions).
Have a look at the /TC and /TP options.
Dave

Opse sorry. I forgot to mention I seen the "Project Properties >
Configuration Properties C/C++ Advanced Compile As" which has
the options:

Compile as C++ (/TP)
Compile as C Code (/TC)

The project is defaulted to /TP (no matter if the extention is .c
or .cpp). Even with /TP set, if the file extentions are all .c it
wont compile. Renaming the files (inside the solution explorer)
without changing any of the project properties (from .c to .cpp) makes
it compile.

As a result it doesn't look like this setting does anything for me
(and the extention on the files are what's dictating compile type). I
was hoping for another property someplace (something like ignore file
extention) kinda thing; or another work-around; or maybe I'm just
using the "Compile As" incorrectly?

Thanks, NB
lol;

I just tried again... When I import the .c files, the default is
indeed set to /TP... (C++), so I thought it was using it.

But then I changed it to /TC, and BACK to /TP.... then tried to
compile... and it works.
So maybe the individual files were set to /TC, and doing this then
sets them all to /TP (even though the main project Properties were
always set to /TP).
Anyway thanks for the help... i did look at this option before, but re-
looking at it has solved my problem! thanks
Mar 6 '08 #4

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

9 posts views Thread by Brian | last post: by
3 posts views Thread by Andrew Luke | last post: by
3 posts views Thread by =?Utf-8?B?QWxleGFuZGVyIFd5a2Vs?= | last post: by
2 posts views Thread by BruceWho | last post: by
5 posts views Thread by Zootal | last post: by
reply views Thread by NPC403 | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.