Solved

QuickC Compiler Error

Posted on 1997-03-24
6
328 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
Free Trending Threat Insights Every Day

Enhance your security with threat intelligence from the web. Get trending threat insights on hackers, exploits, and suspicious IP addresses delivered to your inbox with our free Cyber Daily.

 

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

What Should I Do With This Threat Intelligence?

Are you wondering if you actually need threat intelligence? The answer is yes. We explain the basics for creating useful threat intelligence.

Join & Write a Comment

Suggested Solutions

Title # Comments Views Activity
SQL Statment to match two tables in c# 6 74
Details to do the search 56 144
why "." vs "->" 23 116
Raspberry Pi 3 to send text message 7 16
Preface I don't like visual development tools that are supposed to write a program for me. Even if it is Xcode and I can use Interface Builder. Yes, it is a perfect tool and has helped me a lot, mainly, in the beginning, when my programs were small…
This is a short and sweet, but (hopefully) to the point article. There seems to be some fundamental misunderstanding about the function prototype for the "main" function in C and C++, more specifically what type this function should return. I see so…
The goal of this video is to provide viewers with basic examples to understand opening and reading 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.

747 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

10 Experts available now in Live!

Get 1:1 Help Now