C Help

Eli

Emperor
Joined
Mar 31, 2001
Messages
1,398
Location
Israel
--------------------Configuration: Maman12 - Win32 Debug--------------------
Linking...
main.obj : error LNK2005: _main already defined in disk.obj
main.obj : error LNK2005: _freespace already defined in disk.obj
LIBCD.lib(wincrt0.obj) : error LNK2001: unresolved external symbol _WinMain@16
Debug/Maman12.exe : fatal error LNK1120: 1 unresolved externals
Error executing link.exe.

Maman12.exe - 4 error(s), 0 warning(s)


WTH is that supposed to mean?

I have 3 files.
main.c
disk.c
disk.h

main.c
--------
#include [stdio.h] [ and ] are actually < and >
#include "disk.h"


void main(void)
{
}

disk.c
-------
#include [stdio.h] [ and ] are actually < and >
#include "disk.h"

void main(void)
{}

disk.h
-------

#define NAMELIMIT 10

typedef struct /* one memory cell */
{
char ch;
int track;
int position;
struct cell *next;
} cell;

typedef struct /* one cell in the "files" table */
{
char name[NAMELIMIT];
char info;
cell *file_start;
} file;

typedef struct /* the disk itself */
{
cell *tracks[6];
file *files;
} disk;

int freespace[3]={252,252,252}; /* indicates how much free space there is left on every */
/* disk. Disks are empty at first, so it is initialized */
/* to 4+8+16+32+64+128=252 */



I hate this course.
An advanced C course... And the first thing we need to do is a project, but we arent even familiar with the language yet. :crook:

(this is only the skeleton of the project of course)
 
Well, I know you can't have two main() functions. Are you redefining freespace somewhere as well?
 
Originally posted by jpowers
Well, I know you can't have two main() functions. Are you redefining freespace somewhere as well?

Ok, renaming the main function in disk.c reduced the number of errors to 3.

My first post contained the entire source code, so i'm doing nothing else with freespace.

--------------------Configuration: Maman12 - Win32 Debug--------------------
Linking...
main.obj : error LNK2005: _freespace already defined in disk.obj
LIBCD.lib(wincrt0.obj) : error LNK2001: unresolved external symbol _WinMain@16
Debug/Maman12.exe : fatal error LNK1120: 1 unresolved externals
Error executing link.exe.

Maman12.exe - 3 error(s), 0 warning(s)
 
Hmmm....

After removing the initialization of freespace :
int freespace[3];

I got it down to two errors.

--------------------Configuration: Maman12 - Win32 Debug--------------------
Compiling...
disk.c
Linking...
LIBCD.lib(wincrt0.obj) : error LNK2001: unresolved external symbol _WinMain@16
Debug/Maman12.exe : fatal error LNK1120: 1 unresolved externals
Error executing link.exe.

Maman12.exe - 2 error(s), 0 warning(s)
 
Damn, I hate unresolved externals. I had some in a C++ assignment, unfortunately i can't remember how i got rid of them. The code looks a little weird, but i don't know C, only C++ (ie struct implementation).
 
Back
Top Bottom