Solved

QuickC Compiler Error

Posted on 1997-03-24
6
331 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
PRTG Network Monitor: Intuitive Network Monitoring

Network Monitoring is essential to ensure that computer systems and network devices are running. Use PRTG to monitor LANs, servers, websites, applications and devices, bandwidth, virtual environments, remote systems, IoT, and many more. PRTG is easy to set up & use.

 

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

Control application downtime with dependency maps

Visualize the interdependencies between application components better with Applications Manager's automated application discovery and dependency mapping feature. Resolve performance issues faster by quickly isolating problematic components.

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…
Summary: This tutorial covers some basics of pointer, pointer arithmetic and function pointer. What is a pointer: A pointer is a variable which holds an address. This address might be address of another variable/address of devices/address of fu…
The goal of this video is to provide viewers with basic examples to understand and use structures in the C programming language.
Video by: Grant
The goal of this video is to provide viewers with basic examples to understand and use for-loops in the C programming language.

895 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

Need Help in Real-Time?

Connect with top rated Experts

12 Experts available now in Live!

Get 1:1 Help Now