ProgrammingThis forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.
Notices
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
Get a virtual cloud desktop with the Linux distro that you want in less than five minutes with Shells! With over 10 pre-installed distros to choose from, the worry-free installation life is here! Whether you are a digital nomad or just looking for flexibility, Shells can put your Linux machine on the device that you want to use.
Exclusive for LQ members, get up to 45% off per month. Click here for more info.
I am using Turbo C++, I m getting few errors. I m getting errors on using three header files #include<stdint.h>
#include<sys/time.h>
#include<sys/resource.h> , and function getrusage() should have a prototype. and undefined symbol RUSAGE_SELF please help me to remove these errors
I have written this program to print the voluntary and involuntary context switches. I am getting few errors. please help me to remove these errors
Code:
#include<stdio.h>
#include<time.h>
#include<stdint.h>
#include<sys/time.h>
#include<sys/resource.h>
int main(int argc, char* argv[])
{
struct rusage{
long ru_maxrss;
long ru_ixrss;
long ru_idrss;
long ru_isrss;
long ru_minflt;
long ru_majflt;
long ru_nswap;
long ru_inblock;
long ru_oublock;
long ru_insgsnd;
long ru_msgrcv;
long ru_nsignals;
long ru_nvcsw;
long ru_nivcsw;
};
rusage ru;
getrusage(RUSAGE_SELF, &ru);
printf("voluntary context switches%ld, involuntary context switches %ld",ru.ru_nvcsw,ru.ru_nivcsw);
return 0;
}
I am using Turbo C++, I m getting few errors. I m getting errors on using three header files
#include<stdint.h>
#include<sys/time.h>
#include<sys/resource.h> , and function getrusage() should have a prototype. and undefined symbol RUSAGE_SELF please help me to remove these errors
First, use CODE tags when posting source code. Secondly, what errors are you getting on the header files?
For the prototype message, you've not declared it (as in, putting "void getrusage.....") before entering main. And the undefined symbol is VERY obvious...you're using it, but haven't DEFINED IT ANYWHERE. Also...Turbo C++ is for Windows....the rusage things you're doing here appear to be pulled almost verbatim from the getrusage man page in Linux.
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.