From 81d6790acf9d55a63575efd93bdba1629c101b62 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bj=C3=B6rn=20Gustavsson?= Date: Fri, 16 Nov 2012 07:26:07 +0100 Subject: Suppress warnings for unused variables using a compiler option Currently, the generated code suppresses warnings for unusued variables by assigning to the "_Val" variable, for example: _Val = Tmpval5 To be completely safe, that should have been: _ = Tmpval5 in case there happens to more than one such assignment in the same scope. However, a better way to suppress warnings is to simply use the 'nowarn_unused_vars' compiler option. That method will also work for more complicated expressions there it would be cumbersome to suppress warnings by assignment to "_". --- lib/asn1/src/asn1ct_constructed_per.erl | 4 +--- lib/asn1/src/asn1ct_gen.erl | 2 +- 2 files changed, 2 insertions(+), 4 deletions(-) (limited to 'lib/asn1/src') diff --git a/lib/asn1/src/asn1ct_constructed_per.erl b/lib/asn1/src/asn1ct_constructed_per.erl index e4e0e064e8..46034622c8 100644 --- a/lib/asn1/src/asn1ct_constructed_per.erl +++ b/lib/asn1/src/asn1ct_constructed_per.erl @@ -76,9 +76,7 @@ gen_encode_constructed(Erule,Typename,D) when is_record(D,type) -> case {Optionals = optionals(to_textual_order(CompList)),CompList, is_optimized(Erule)} of {[],EmptyCL,_} when EmptyCL == {[],[],[]};EmptyCL == {[],[]};EmptyCL == [] -> - emit(["%%Variable setting just to eliminate ", - "compiler warning for unused vars!",nl, - "_Val = ",{curr,val},",",nl]); + ok; {[],_,_} -> emit([{next,val}," = ",{curr,val},",",nl]); {_,_,true} -> diff --git a/lib/asn1/src/asn1ct_gen.erl b/lib/asn1/src/asn1ct_gen.erl index b0990e92cf..57b12ce186 100644 --- a/lib/asn1/src/asn1ct_gen.erl +++ b/lib/asn1/src/asn1ct_gen.erl @@ -1405,7 +1405,7 @@ gen_head(Erules,Mod,Hrl) -> emit({"%% Purpose: encoder and decoder to the types in mod ",Mod,nl,nl}), emit({"-module('",Mod,"').",nl}), put(currmod,Mod), - %emit({"-compile(export_all).",nl}), + emit({"-compile(nowarn_unused_vars).",nl}), case {Hrl,lists:member(inline,get(encoding_options))} of {0,_} -> true; {_,true} -> true; -- cgit v1.2.3