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 5 articles in this topic
Showing 5 of 828 articles.
Currently 126 other people reading this forum.


 UWA week 37 (2nd semester, week 7) ↓
SVG not supported

Login to reply

👍?
helpful
12:31am Fri 13th Sep, Harrison L.

Hello,

I understand that the program must be compiled using the command:

cc -std=c11 -Wall -Werror -o runml runml.c

But must the translated code produced by the program do the same? Because this would cause issues depending on the ML code written. Such as:

var <- 6
print 7

Since var is not used, Werror would throw an error!

ml-51566.c:14:8: error: unused variable 'var' [-Werror,-Wunused-variable]
double var = 8;
       ^
1 error generated.

This would not be a fault of the project programmer, but of the test itself. Should this be caught by the compiler, or can we compile using cc/gcc instead of the more intensive error checking.

Thanks.


SVG not supported

Login to reply

👍?
helpful
7:14am Fri 13th Sep, Joshua N.

"Harrison Lisle" [email protected] wrote:

Hello,

I understand that the program must be compiled using the command:

cc -std=c11 -Wall -Werror -o runml runml.c

But must the translated code produced by the program do the same? Because this would cause issues depending on the ML code written. Such as:

var <- 6
print 7

Since var is not used, Werror would throw an error!

ml-51566.c:14:8: error: unused variable 'var' [-Werror,-Wunused-variable]
double var = 8;
       ^
1 error generated.

This would not be a fault of the project programmer, but of the test itself. Should this be caught by the compiler, or can we compile using cc/gcc instead of the more intensive error checking.

Thanks.

If you want to be 100% sure you can ask Amitava.

You can always do something with var to remove the warning. Literally just do var = var*1 and the warning will go away.


SVG not supported

Login to reply

👍?
helpful
3:27pm Fri 13th Sep, Amitava D.

"Harrison Lisle" [email protected] wrote:

Hello,

I understand that the program must be compiled using the command:

cc -std=c11 -Wall -Werror -o runml runml.c

But must the translated code produced by the program do the same? Because this would cause issues depending on the ML code written. Such as:

var <- 6
print 7

Since var is not used, Werror would throw an error!

ml-51566.c:14:8: error: unused variable 'var' [-Werror,-Wunused-variable]
double var = 8;
       ^
1 error generated.

This would not be a fault of the project programmer, but of the test itself. Should this be caught by the compiler, or can we compile using cc/gcc instead of the more intensive error checking.

Thanks.

Use gcc without -Werror.


 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