Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

C versus C++

Status
Not open for further replies.

DougP

MIS
Dec 13, 1999
5,985
0
36
US
I want to use Microsoft Visual Studio .NET 2005
I am using a freebie editor but it does not allow line at a time debugging like Microsoft. showing stop points and viewing variable live while running.
if I paste my C code into a C++ project it usually will never run. first it says :
Did you forget to add '#include "stdafx.h"' to your source?
if I add it then I get
'Debug\linky.pch' precompiled header file is from a previous version of the compiler, or the precompiled header is C++ and you are using it from C (or vice versa)
so how do I fix it?
I tried naming the files xxx.c and xxx.cpp

are there options or settings to make Microsoft C++ work like ANSI C?

TIA


DougP
 
if I make the files .cpp then I get this error

error C2440: '=' : cannot convert from 'void *' to 'TCell *'

Code:
#include "stdafx.h"
#include "stdio.h"
#include "linky.h"

TCell* TCell_create ( int data )
{ 
	TCell* p;
	p = malloc(sizeof(TCell));//<<<<<<< Error here
	if (p == NULL ) 	return NULL;
	p->data = data;
	p->next = NULL;
	
	return p;p

DougP
 
> if I paste my C code into a C++ project it usually will never run. first it says :
> Did you forget to add '#include "stdafx.h"' to your source?
Step 1 is goto project->settings->compiler and find the settings for precompiled headers.
Then turn it OFF.

Then you can delete stdafx.h from your project, remove it from your source files, and generally forget about it.

Then make sure your programs are called prog.c and you should be good to go.

> error C2440: '=' : cannot convert from 'void *' to 'TCell *'
That's because C++ doesn't support silent casting of void* to a type.


--
If you dance barefoot on the broken glass of undefined behaviour, you've got to expect the occasional cut.
 
OK first of all this is VS 2005. when I click on Project there is no option menu.
there is the project name and properties such as MyProject properties...
but under that option there is nothing like you mentioned.

under Tools menu there is Options
there are a ton of choices under on the left side list.
I looked carefully at everything and don't see "compiler" anything. !!!



DougP
 
its Visual Studio 2005 Professional
8.0.50727.42
I installed everything VB, C++, C# ,J# etc

DougP
 
maybe another question is what kind of project should I be creating?
I using C++ / Win32 / Win32 Console Application

DougP
 
that still does not work correct. it want's to create .cpp file every time. even if I type myfile.c it makes myfile.c.cpp

and the words/options don't match exactly as what is says and what I see.

i need an IDE that can do line by line debugging.

any other ideas?

DougP
 
Rename myfile... to myfile.c - thst's all.

>i need an IDE that can do line by line debugging.
MS Visual Studio has the best in the world "line by line" debugger. What else do you want?

However VC++ does not implement current C language standard.
 
your quote:
"However VC++ does not implement current C language standard."

Oh Ok now I get it. So there is no hope then of ever making it work.

DougP
 
DougP said:
I am using a freebie editor but it does not allow line at a time debugging like Microsoft. showing stop points and viewing variable live while running.
...
i need an IDE that can do line by line debugging
You didn't say what compiler you used before MS VC++.
I don't want to suggest you, that you shouldn't use MS VC++, but if you didn't like it and you used MinGW gcc before and you only need a debugger, you can use gdb with graphical user interface called insight. Another alternative is an IDE called Code::Blocks IDE ... or eclipse CDT

 
here is a little background:
yes I am using several editors with gcc as the compiler.
Xemacs, Crimson, CFree pro demo. CFree demo did not allow debugging though even though it showed in the menus.
Having VS 2005 I tried pasting the code from the Crimson into the VS IDE and it would not compile even though it did in Crimson with gcc.
I want to continue to learn C/ C++ and C# perhaps, and java.

I bought VS2005 several years ago and use it for VB.net and ASP.net with vb. I have used Visual Basic since it was created in 1991-ish all the way to VB6 which I still use today. I use and love Microsoft Access since ver 1.1 and today using Access 2002, 2003, 2007, I find using the MS VBA IDE which is identical to VB6 and the other newer IDE's a wonderful experience. I have come to depend on all it offers to make my program work. particularity debug.print, stopping points using F9, pressing F8 to see where the program goes line by line and hovering over variables while a program is running to see their values. Intellesense, jumping to a line of code that has an error, etc.
This has made the difference in learning VB/VBA to its fullest but "NOT" being able to learn C hardly at all since the editors I have used are not as powerful. Its as though I blind and fumbling around.


DougP
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top