Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

QuickC Compiler Error

Posted on 1997-03-24
6
Medium Priority
?
358 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
Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

 

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 150 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

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

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…
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 recursion 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.

927 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