Learn how to a build a cloud-first strategyRegister Now

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 390
  • Last Modified:

error installing software

Hi

While installing some software i got this error

Fasta.cpp: In member function ‘std::string FastaReference::getSequence(std::string)’:
Fasta.cpp:266: warning: ignoring return value of ‘size_t fread(void*, size_t, size_t, FILE*)’, declared with attribute warn_unused_result
Fasta.cpp: In member function ‘std::string FastaReference::getSubSequence(std::string, int, int)’:
Fasta.cpp:308: warning: ignoring return value of ‘size_t fread(void*, size_t, size_t, FILE*)’, declared with attribute warn_unused_result

I was advised to 'Try to include #include <cstring>' however i don't know what that means as i don't program in C++ how i would i go about doing it.

Any advice much appreciated

[corrected zone from C# to C++ - mrjoltcola / Zone Advisor]
0
andieje
Asked:
andieje
1 Solution
 
phoffricCommented:
There are no errors, just warnings.

When you use fread, the program should check the return values.

Return Value
"The total number of elements successfully read is returned as a size_t object, which is an integral data type."
"If this number differs from the count parameter, either an error occured or the End Of File was reached."
"You can use either ferror or feof to check whether an error happened or the End-of-File was reached."

    http://www.cplusplus.com/reference/clibrary/cstdio/fread/

If you have want to modify the code, I can help you modify it to remove the warning.
0
 
farzanjCommented:
Edit Fasta.cpp file

At the top of the file, along with other include statements, just include

#include<cstring>

Also, please show the file

cat Fasta.cpp
0
 
wesly_chenCommented:
Could please provide
- What software you try to install
- Which Linux do you have (Ubuntu, Fedora, CentOS/RedHat) and the version?
-
0
Windows Server 2016: All you need to know

Learn about Hyper-V features that increase functionality and usability of Microsoft Windows Server 2016. Also, throughout this eBook, you’ll find some basic PowerShell examples that will help you leverage the scripts in your environments!

 
phoffricCommented:
If you have no errors, but only warnings, then your program should build OK and run.

The warning means that there could have been extra error checking on the reading of a file. Since, most of the time, fread does not return an error (once the software is working well and the file is properly opened with error checking to prevent reading from, say, a non-existent file), then the program should work OK.

But good programming practices dictates that every C/C++ library call that returns an error condition should be checked for an error.
0
 
mrjoltcolaCommented:
Just add a return variable for fread so it is not ignored and the compiler will be happy.
Just find the locations of the fread calls and change

fread();

to

size_t ret;
ret = fread();
0
 
andiejeAuthor Commented:
hello phoffric my old friend. is there anything you don't do???

Fasta.cpp is too long to show.

I've already installed the software (by the commands make clean and make all). If the warning is harmless and the program will run ok i will leave it. It seems to be ok but i don't know enough to know if it is ok behind the scenes
0
 
phoffricCommented:
hello andieje my old friend. I don't do lots of anything, LOL.

Have you abandoned the teaching idea?

If your program seems to work, then great. If it stops working someday, the library call return status (if present) certainly help in analyzing the problem. If a file exist, but still gives problems, it could even be a permissions problem that you may have realized. But if proper error handling were in place, then an application error message would be displayed for you to remedy the problem.
0
 
andiejeAuthor Commented:
i had to put the teaching on hold for a year due to family problems but everything has changed in this country wrt teaching - huge cuts and no jobs so don't know what i will do. Luckily i have some brains (though not as many as you) so retraining is not an issue (though i may have to turn my back on the astrophysics world)
0
 
phoffricCommented:
huge cuts in teaching here also. my son had signed up to begin a masters in education when he just heard of the huge cuts and cancelled registration.

no more brains than you. just focussed on different things. you can walk spheres around me in the IT world.
0
 
andiejeAuthor Commented:
says the man solving my IT question :)

The one thing I found i've enjoyed most in my career is creating resources for teaching as I like the creativity of finding analogies and models to explain concepts. I might do the teacher training to give me the credibility i need to get into writing educational resources.

I have not found research to be that fulfilling. It is just politics and egos and very very slow. It's not the band of altruists working towards a common goal and the good of mankind that i hoped. It's just a game of knocking out as many papers as you can as quickly as you can
0
 
phoffricCommented:
>> It's not the band of altruists working towards a common goal and the good of mankind
Long time ago, I saw 3 Nobel Prize Winners (at least 2 in physics) being interviewed. Eventually, it came around to why they did the work they did - was it (something along the lines about what you just mentioned). I was really surprised to hear them say that the hard work and study was for the "prize" and the "recognition" that they were great. And here I thought it was for their love of knowledge.
0

Featured Post

NFR key for Veeam Agent for Linux

Veeam is happy to provide a free NFR license for one year.  It allows for the non‑production use and valid for five workstations and two servers. Veeam Agent for Linux is a simple backup tool for your Linux installations, both on‑premises and in the public cloud.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now