Solved

QuickC Compiler Error

Posted on 1997-03-24
6
332 Views
Last Modified: 2012-05-04
I just reinstalled my old copy of QuickC, and have been
playing around with converting some short programs. The
problem I have is that when I compile in memory I get
a C2175 error. This means that the function is invalid
and I shold include or define the function. Evidently
this only happens with short progs compiled in memory and isnt supposed to occur when doing to exe etc.

I cut things back to the point where I was only working
with 3-4 lines of code (gen a rand number and display) but
I still got the same error. My paths are good etc and in
the case of the include's the prog is finding the right one.
So how Can I work around this, so I can compile to memory
and check my code. It says I should include the lib (which i have) or define the function. Is there another way around this?

Dave
0
Comment
Question by:kingd
6 Comments
 
LVL 1

Expert Comment

by:warren_dale
ID: 1249740
Give us a tiny but complete program displaying the error.
0
 

Author Comment

by:kingd
ID: 1249741
As requested here is a very short chunk of code
that will produce the C2175 error.

#include <stdlib>
main()
{
    int x;
    for (x = 1; x <= 20; x++)
    printf("Iteration %d, rand = %d", x, rand());
    }

If I try to define rand say as rand(void) I get not enough
paramitors,
0
 
LVL 4

Expert Comment

by:jos010697
ID: 1249742
My guess is that it's not your compiler that's complaining --
it's your linker. It can't find a definition of the rand() function,
because you didn't supply it with the corresponding library.
Check the linker options ...

Just a guess though; I know nothing about quickC

BTW: change your first line to:

#include <stdlib.h>

kind regards,

Jos aka jos@and.nl
0
ScreenConnect 6.0 Free Trial

Explore all the enhancements in one game-changing release, ScreenConnect 6.0, based on partner feedback. New features include a redesigned UI, app configurations and chat acknowledgement to improve customer engagement!

 

Author Comment

by:kingd
ID: 1249743
The <stdlib.h> is correct in my code. However typing
it in again managed to make the odd error. Code I am
compiling has no syntax errors (unlike my typing ;-])

Dave
0
 
LVL 1

Expert Comment

by:warren_dale
ID: 1249744
How about adding:
    #include <stdio.h>
Does this help?
0
 
LVL 1

Accepted Solution

by:
roy020697 earned 50 total points
ID: 1249745
Since this remains unanswered, I'll agree with the previous posted answers and add a run-time comment. Your code should compile cleanly by including <stdio.h> for the printf() prototype and <stdlib.h> for the rand() prototype. Run time Comment: In addition, you should precede the use of rand() with srand() to seed the random number generator. This shouldn't affect compiling, however.

Maybe your compiler is complaining about the main() declaration having no parameters?

Check you code carefully -- especially the first two include statements. It should look like this:

#include <stdio.h>
#include <stdlib.h>
int main( int argc, char *argv[])
{
   int x;

   srand( 1 );   /* instead of 1, use an unsigned seed value */
                 /* that changes, like */
                 /* srand(( unsigned )time( NULL )); */
                 /* time() needs time.h included. */
   for( x = 1; x <= 20; x++ )
      printf( "Iteration %d, rand = %d", x, rand());
   return( 0 );
}
0

Featured Post

Does Powershell have you tied up in knots?

Managing Active Directory does not always have to be complicated.  If you are spending more time trying instead of doing, then it's time to look at something else. For nearly 20 years, AD admins around the world have used one tool for day-to-day AD management: Hyena. Discover why

Question has a verified solution.

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

An Outlet in Cocoa is a persistent reference to a GUI control; it connects a property (a variable) to a control.  For example, it is common to create an Outlet for the text field GUI control and change the text that appears in this field via that Ou…
Examines three attack vectors, specifically, the different types of malware used in malicious attacks, web application attacks, and finally, network based attacks.  Concludes by examining the means of securing and protecting critical systems and inf…
The goal of this video is to provide viewers with basic examples to understand opening and writing to files in the C programming language.
The goal of this video is to provide viewers with basic examples to understand and use conditional statements in the C programming language.

773 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