Solved

LOTS of errors while trying to compile md5 code from site

Posted on 2004-09-02
8
965 Views
Last Modified: 2008-01-09
Hello.
I tried to compile the code from http://www.faqs.org/rfcs/rfc1321.html which should calculate an md5 from a string.
I got the following errors:
*******
Compiling...
md5c.c
test_md5.c
test_md5.c(106) : error C2065: 'MD_CTX' : undeclared identifier
test_md5.c(106) : error C2146: syntax error : missing ';' before identifier 'context'
test_md5.c(106) : error C2065: 'context' : undeclared identifier
test_md5.c(107) : error C2143: syntax error : missing ';' before 'type'
test_md5.c(108) : error C2143: syntax error : missing ';' before 'type'
test_md5.c(110) : warning C4013: 'MDInit' undefined; assuming extern returning int
test_md5.c(111) : warning C4013: 'MDUpdate' undefined; assuming extern returning int
test_md5.c(111) : error C2065: 'len' : undeclared identifier
test_md5.c(112) : warning C4013: 'MDFinal' undefined; assuming extern returning int
test_md5.c(112) : error C2065: 'digest' : undeclared identifier
test_md5.c(114) : error C2065: 'MD5' : undeclared identifier
test_md5.c(124) : error C2146: syntax error : missing ';' before identifier 'context'
test_md5.c(125) : error C2275: 'time_t' : illegal use of this type as an expression
        c:\program files\microsoft visual studio\vc98\include\time.h(79) : see declaration of 'time_t'
test_md5.c(125) : error C2146: syntax error : missing ';' before identifier 'endTime'
test_md5.c(125) : error C2065: 'endTime' : undeclared identifier
test_md5.c(125) : error C2065: 'startTime' : undeclared identifier
test_md5.c(126) : error C2143: syntax error : missing ';' before 'type'
test_md5.c(127) : error C2143: syntax error : missing ';' before 'type'
test_md5.c(134) : error C2065: 'i' : undeclared identifier
test_md5.c(135) : error C2065: 'block' : undeclared identifier
test_md5.c(135) : error C2109: subscript requires array or pointer type
test_md5.c(135) : error C2106: '=' : left operand must be l-value
test_md5.c(183) : error C2146: syntax error : missing ';' before identifier 'context'
test_md5.c(184) : error C2143: syntax error : missing ';' before 'type'
test_md5.c(185) : error C2143: syntax error : missing ';' before 'type'
test_md5.c(192) : error C2065: 'buffer' : undeclared identifier
test_md5.c(192) : warning C4022: 'fread' : pointer mismatch for actual parameter 1
test_md5.c(208) : error C2146: syntax error : missing ';' before identifier 'context'
test_md5.c(209) : error C2143: syntax error : missing ';' before 'type'
test_md5.c(210) : error C2143: syntax error : missing ';' before 'type'
test_md5.c(213) : warning C4022: 'fread' : pointer mismatch for actual parameter 1
Error executing cl.exe.
*********
I copied and pasted the code directly, so I don't know what I'm doing wrong....

(PS.: is there also an option to tell the compiler explicitly to compile the files as C and not as C++ , or should I just give the files a C-extention in stead of .cpp ??)
0
Comment
Question by:Confettis
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 3
  • 2
  • 2
  • +1
8 Comments
 
LVL 45

Expert Comment

by:sunnycoder
ID: 11962378
Are you sure you have the files copied properly and you are not mixing some of the code around ....

I see MD_CTX defined there
0
 
LVL 7

Assisted Solution

by:aib_42
aib_42 earned 20 total points
ID: 11962863
You have two files called "md5.h" and "globals.h", or you changed the #include "global.h" / #include "md5.h" part, right?
0
 

Author Comment

by:Confettis
ID: 11967758
Hi, and thanks for your replies.

sunnycoder, yes I am sure that that's not the error, I checked it several times....
aib_42, no, I don't have changed this part, neither have I more than one file with the same name .....

Did one of you tried to compile the files ??? (and, if so, did you had errors ??)
0
Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
LVL 3

Expert Comment

by:teratoma
ID: 11970477
The include path needs to be supplied to the compiler.  This is usually in the form of "-I<filename>" on the command line.
0
 
LVL 7

Expert Comment

by:aib_42
ID: 11977687
I see you have renamed md5.c to test_md5.c. If this is the case for other files too, you would have to modify the #include lines all over the source code.
0
 

Author Comment

by:Confettis
ID: 11977845
Thanks,
teratoma, I did this (I'm using Visual studio)
aib_42, It's not the "md5c.c" I renamed but the "MDDRIVER.C", which was a "sample testing program"

I'm starting to get desperate....
0
 
LVL 3

Accepted Solution

by:
teratoma earned 150 total points
ID: 11978028
Hmm, these people are using some rather evil preprocessor stuff:

#ifndef MD
#define MD MD5
#endif

...

#if MD == 5
#include "md5.h"
#endif

...

#if MD == 5
#define MD_CTX MD5_CTX
#define MDInit MD5Init
#define MDUpdate MD5Update
#define MDFinal MD5Final
#endif

What if MD5 isn't defined (and I think it's not)?  This might cause the error you're seeing.  Try replacing this

#define MD MD5

with this:

#define MD 5

and see what happens.

Anyone ever mention that the preprocessor should be used sparingly?
0
 

Author Comment

by:Confettis
ID: 11980070
thanks teratoma; this was indeed correct. It is working now.
0

Featured Post

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Have you thought about creating an iPhone application (app), but didn't even know where to get started? Here's how: ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ Important pre-programming comments: I’ve never tri…
Windows programmers of the C/C++ variety, how many of you realise that since Window 9x Microsoft has been lying to you about what constitutes Unicode (http://en.wikipedia.org/wiki/Unicode)? They will have you believe that Unicode requires you to use…
The goal of this video is to provide viewers with basic examples to understand recursion in the C programming language.
The goal of this video is to provide viewers with basic examples to understand and use switch statements in the C programming language.
Suggested Courses

732 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question