Solved

QuickC Compiler Error

Posted on 1997-03-24
6
337 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
Optimizing Cloud Backup for Low Bandwidth

With cloud storage prices going down a growing number of SMBs start to use it for backup storage. Unfortunately, business data volume rarely fits the average Internet speed. This article provides an overview of main Internet speed challenges and reveals backup best practices.

 

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

Efficient way to get backups off site to Azure

This user guide provides instructions on how to deploy and configure both a StoneFly Scale Out NAS Enterprise Cloud Drive virtual machine and Veeam Cloud Connect in the Microsoft Azure Cloud.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
How to organize data in excel ? 2 115
why "." vs "->" 23 120
distributed computing in Python 4 137
How to build c program using make in mingw environment? 9 71
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…
This tutorial is posted by Aaron Wojnowski, administrator at SDKExpert.net.  To view more iPhone tutorials, visit www.sdkexpert.net. This is a very simple tutorial on finding the user's current location easily. In this tutorial, you will learn ho…
The goal of this video is to provide viewers with basic examples to understand how to use strings and some functions related to them 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.

860 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