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 IamaSherpa on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

How to deal from C files in Visual C++ 6.0 3

Status
Not open for further replies.

thierrypp

Technical User
Jan 17, 2006
16
CH
Hello!

May I ask you how to proceed for using my Visual C++ 6.0 compiler for C files.
I encounter a lot of errors however my cC programmes work well on C compilers.

Any idea?

Thanks a lot,

T
 
What sort of errors? Could you give some examples?
 
yes, here is the message errors:
--------------------Configuration: ggggg - Win32 Debug--------------------
Compiling resources...
Compiling...
StdAfx.cpp
Compiling...
ggggg.cpp
C:\Documents and Settings\atvd\Desktop\New Folder00ppp\ggggg\ggggg.cpp(59) : warning C4508: 'main' : function should return a value; 'void' return type assumed
C:\Documents and Settings\atvd\Desktop\New Folder00ppp\ggggg\ggggg.cpp(22) : warning C4101: 'j' : unreferenced local variable
Linking...
LIBCD.lib(wincrt0.obj) : error LNK2001: unresolved external symbol _WinMain@16
Debug/ggggg.exe : fatal error LNK1120: 1 unresolved externals
Error executing link.exe.

ggggg.exe - 2 error(s), 2 warning(s)
=============================================

and the original code:
// ggggg.cpp : Defines the entry point for the application.
//

#include "stdafx.h"
#include "resource.h"

/* ---------- */
/* tri_noms.c */
/* ---------- */
#include <stdio.h>
#include <string.h>

#define NB_PERSONNES 50
#define TAILLE_NOM 20

main()
{
int nbpersonnes=0, termine=0;
char liste_personnes[NB_PERSONNES][TAILLE_NOM] ;

char nom[TAILLE_NOM], tempnom[TAILLE_NOM] ;
int i,j,k;

/* --- boucle de saisie des noms --- */
while (! termine)
{
printf("Entrez un nom ( nom=fin pour terminer):");
scanf("%s",nom);

termine=((strcmp(nom,"fin"))==0) ;
if (! termine)
{ /* rangement dans te tableau */
strcpy(liste_personnes[nbpersonnes],nom) ;
nbpersonnes++ ;
}
}
/* --- boucle de tri du tableau --- */
for (i=0 ; i < nbpersonnes ; i++)
{
k=i ;
/* boucle inverse, d'inversion des cases */
/* tant que le nom dans la case k est */
/* "plus petit" que celui de la case k-1 */
while ((k>0) && (strcmp(liste_personnes[k],liste_personnes[k-1])<0))
{
/* on inverse avec la fonctions strcmp */
strcpy(tempnom,liste_personnes[k-1]) ;
strcpy(liste_personnes[k-1],liste_personnes[k]);
strcpy(liste_personnes[k],tempnom);
k--;
}
}

/* --- boucle d'affichage des noms --- */
for (i=0 ; i< nbpersonnes ; i++)
{
printf("nom de la personne %d:%s\n",i,liste_personnes);
}
}

=============================================

I followed all the procedures mentionned in forums.

However if you can tell me the right way...
I work with Visual C++ 6.0

Thanks a lot,

T.
 
You've set up your project to build a Windows GUI application and provided a console application's main.
 
The main() function should be:
Code:
int main()
Then add: return 0; at the end of the main() function.

You declare int j, but don't use it anywhere. The compiler is telling you to either get rid of j, or use it somewhere.

Also, since that is a pure C file, you should probably name it ggggg.c instead of .cpp.
 
thanks,

here is the result:

Compiling resources...
Compiling...
StdAfx.cpp
Compiling...
aaaaa.cpp
C:\Documents and Settings\atvd\Desktop\New Folder00ppp\aaaaa\aaaaa.cpp(22) : warning C4101: 'j' : unreferenced local variable
C:\Documents and Settings\atvd\Desktop\New Folder00ppp\aaaaa\aaaaa.cpp(61) : warning C4715: 'main' : not all control paths return a value
Linking...
LIBCD.lib(wincrt0.obj) : error LNK2001: unresolved external symbol _WinMain@16
Debug/aaaaa.exe : fatal error LNK1120: 1 unresolved externals
Error executing link.exe.

aaaaa.exe - 2 error(s), 2 warning(s)
 
You are still running it as a windows project. Have a look at the command line on the link. Change subsystem:Windows to subsystem:console.
 
You still need to get rid of 'j', and you still need to add: return 0; to the end of main().
 
same error.

moreover I followed also all from:

PRB: Link Error LNK2001: Unresolved External Symbol _main
at MIcrosoft Help and support
 
I think the best way to deal with an external C sources pack in VC++ 6.0 is:
1. Create (by Wizard) an empty Win32 Console Application project.
2. Place all C files (.c and .h) in the project folder.
3. Add to Project (Project|Add To Project|Files...) all these files.
4. That's all, but don't forget to add .c extention for new source file names (because of .cpp will be added by default but the compiler recognize source language by extention - and C is not only subset of C++).
 
Thanks a lot!

However in fact I have had following your advice to modify several procedures.
VC ++ 6.0 remains very attached to cpp

as a typical illustration

ad void to main ()

etc......


But I noticed an IDE compiling only C files and compatible with VC++, called Lcc-Win32 do you know it?
freeware but I wonder if it is a very reliable one with several *.h files in a project......

Best regards,
Thierry
 
void to main - what? Must be int main()[/b] in C and C++. For example, try
Code:
typedef struct S { int x; int y; } S;
S* p = malloc(sizeof(S));
in .cpp file - it's an error, but in .c is OK (VC++ 6.0).
Or try
Code:
int f() { ... }
...
f(1);
It's an error in .cpp file but OK in .c. Alas, VC++ 6.0 does not know the current C Standard...
Now I use C++ only with VC++ and (sometimes) Dev-C++ (and C with Turbo C 2.0 many years ago). I have used an approach described above with legacy C codes (sometimes with minimal sources correction).
 
How can you manage DevC/c++ that I know with Visual C++ 6.0?

I tried two weeks ago and all was mixed...

can you download without problems the two ides?

by the way did you test Lcc-Win32 (freeware) for only C but very hard todeal with!

Regards,
T.
 
I never mix VC++ and Dev-C++ codes. I think it's impossible (and no need with all sources)
Download Dev-C++ only (less than 50 Mb). My VC++ is on CD-ROM distributives (VS Enterprise Ed).
Sorry but now I'm working with C++ projects only so I don't know about modern pure C compilers. But if you have modern (not a classic) C sources, you need the better than VC++ 6.0 compiler, I agree...
 
If you want to use something a little more standard compliant, you can download and use Visual C++ 2005 express edition for 1 year.

It has a compiler option to compile using either C or C++ rules. If you get 2005 express edition, you'll need to get the platform SDK and do all the other steps listed on that page.
 
but is it compatible with Visual C++ 6.0?

and moreover, did you already try the LCC-WIN32 for C programming at Qsoftware solutions?

Thanks
Regards,
T.
 
I'm not sure if you're talking to me or ArkM, but VC++ 2005 uses different project and workspace files, so you'd need to convert your .dsp and .dsw files. Luckily it will ask you and then do it for you. However, you can't convert the 2005 .vcproj and .sln files back to 6.0 .dsw and .dsp files.
 
To you of course cpjust!
Thank you,

So, if I have well understood, I can work with VC++ 2005 and keep my .dsp and .dsw ... files intacts from VC C++ 6.0

and no conflicts with VC2005 express, from which I can easily work with C files, right?
 
You can keep a backup of your .dsp and .dsw files in case you want to switch back to VC++ 6.0 later, but to use VC++ 2005 they'll have to be converted to .vcproj and .sln files.

I've created a pure C program with VC++ 2005 without any problems.

When you create projects with VC++ 2005, it will try to make them managed (i.e. .NET) by default, so you will need to change some of the default project settings.

BTW, you can also have both VC++ 6.0 and VC++ 2005 installed at the same time. You don't need to uninstall 6.0 before you install 2005.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top