Improve company productivity with a Business Account.Sign Up

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 1017
  • Last Modified:

LOTS of errors while trying to compile md5 code from site

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
Confettis
Asked:
Confettis
  • 3
  • 2
  • 2
  • +1
2 Solutions
 
sunnycoderCommented:
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
 
aib_42Commented:
You have two files called "md5.h" and "globals.h", or you changed the #include "global.h" / #include "md5.h" part, right?
0
 
ConfettisAuthor Commented:
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
Easily Design & Build Your Next Website

Squarespace’s all-in-one platform gives you everything you need to express yourself creatively online, whether it is with a domain, website, or online store. Get started with your free trial today, and when ready, take 10% off your first purchase with offer code 'EXPERTS'.

 
teratomaCommented:
The include path needs to be supplied to the compiler.  This is usually in the form of "-I<filename>" on the command line.
0
 
aib_42Commented:
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
 
ConfettisAuthor Commented:
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
 
teratomaCommented:
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
 
ConfettisAuthor Commented:
thanks teratoma; this was indeed correct. It is working now.
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

Join & Write a Comment

Featured Post

Has Powershell sent you back into the Stone Age?

If managing Active Directory using Windows Powershell® is making you feel like you stepped back in time, you are not alone.  For nearly 20 years, AD admins around the world have used one tool for day-to-day AD management: Hyena. Discover why.

  • 3
  • 2
  • 2
  • +1
Tackle projects and never again get stuck behind a technical roadblock.
Join Now