It's UWAweek 47

help2002

This forum is provided to promote discussion amongst students enrolled in CITS2002 Systems Programming.
Please consider offering answers and suggestions to help other students! And if you fix a problem by following a suggestion here, it would be great if other interested students could see a short "Great, fixed it!"  followup message.
Displaying the 2 articles in this topic
Showing 2 of 831 articles.
Currently 2 other people reading this forum.


 UWA week 38 (2nd semester, week 8) ↓
SVG not supported

Login to reply

👍?
helpful
9:29pm Mon 16th Sep, Samay G.

I recall that on my question on this thread (https://secure.csse.uwa.edu.au/run/help2002?p=np&opt=U308) it was proposed that we compile code without -Werror, but even if we just use -Wall it also throws all warnings, is that expected and fine? Here is example:

My sample translated code is: #include <stdio.h> int main(int argc, char *argv[]) { double x; x = 2.3; print 5; return 0; }

I am compiling this translated c code using "cc -std=c11 -Wall -o mycode mycode.c "

I am getting this warning error: warning: variable ‘x’ set but not used [-Wunused-but-set-variable] 6 | double x; | ^ 5

(Note that "5" is printed just fine)


SVG not supported

Login to reply

👍?
helpful
3:37pm Tue 17th Sep, Joshua N.

"Samay Gupta" [email protected] wrote:

I recall that on my question on this thread (https://secure.csse.uwa.edu.au/run/help2002?p=np&opt=U308) it was proposed that we compile code without -Werror, but even if we just use -Wall it also throws all warnings, is that expected and fine? Here is example:

My sample translated code is: #include <stdio.h> int main(int argc, char *argv[]) { double x; x = 2.3; print 5; return 0; }

I am compiling this translated c code using "cc -std=c11 -Wall -o mycode mycode.c "

I am getting this warning error: warning: variable ‘x’ set but not used [-Wunused-but-set-variable] 6 | double x; | ^ 5

(Note that "5" is printed just fine)

Just multiply x by 1 in the code.

e.g. x = x*1; and the error/warning will go away.

The University of Western Australia

Computer Science and Software Engineering

CRICOS Code: 00126G
Written by [email protected]
Powered by history
Feedback always welcome - it makes our software better!
Last modified  8:08AM Aug 25 2024
Privacy policy