我有一些实现接口的类,其中一些方法的参数在特定的类实现中定义为未使用。例如,一个"Shape“接口可能定义了一个”包含( point )“方法,但是我的特定类定义了一条线,因为它是一维的,所以它不能包含任何东西,所以它总是返回false,并且从不使用point。
但是,当我使用GCJ进行编译时,会收到数百条“警告:参数x未使用”的消息。
我尝试使用-Wno-all标志禁用警告,以及gcj手册页中记录的其他警告,但这些都没有效果。我如何指示GCJ不要用这些琐碎的警告来打扰我?
发布于 2010-01-14 01:31:02
尽管我还没有找到使用gcj直接执行此操作的选项,但一种变通方法是将输出通过管道传输到grep中,并查找模式"error:",然后只显示该行和周围的几行。
例如: javac *.java 2>&1 | grep -B 3 -A 2 "error:“
发布于 2012-10-09 19:58:18
我已经设法禁用了所有影响我的源代码的警告,使用:
gcj -Wno-all -Wno-unchecked -Wno-raw *.java您可能希望添加更多-Wno-...标志以禁用更多警告。为了找出可能的标志,我检查了Eclipse批处理编译器ecjsrc-3.5.2.zip和ecjsrc-3.8.zip中的方法org.eclipse.jdt.internal.compiler.batch.Main.handleWarningToken和org.eclipse.jdt.internal.compiler.batch.Main.handleErrorOrWarningToken的主体。
指定所有这些标志以禁用所有警告:
-Wno-all
-Wno-allDeadCode
-Wno-allDeprecation
-Wno-allJavadoc
-Wno-allOver-ann
-Wno-all-static-method
-Wno-assertIdentifier
-Wno-boxing
-Wno-charConcat
-Wno-compareIdentical
-Wno-conditionAssign
-Wno-constructorName
-Wno-deadCode
-Wno-dep-ann
-Wno-deprecation
-Wno-discouraged
-Wno-emptyBlock
-Wno-enumIdentifier
-Wno-enumSwitch
-Wno-enumSwitchPedantic
-Wno-fallthrough
-Wno-fieldHiding
-Wno-finalBound
-Wno-finally
-Wno-forbidden
-Wno-hashCode
-Wno-hiding
-Wno-includeAssertNull
-Wno-incomplete-switch
-Wno-indirectStatic
-Wno-interfaceNonInherited
-Wno-intfAnnotation
-Wno-intfNonInherited
-Wno-intfRedundant
-Wno-javadoc
-Wno-localHiding
-Wno-maskedCatchBlock
-Wno-maskedCatchBlocks
-Wno-nls
-Wno-noEffectAssign
-Wno-noImplicitStringConversion
-Wno-null
-Wno-nullDereference
-Wno-over-ann
-Wno-over-sync
-Wno-packageDefaultMethod
-Wno-paramAssign
-Wno-pkgDefaultMethod
-Wno-raw
-Wno-redundantSuperinterface
-Wno-resource
-Wno-semicolon
-Wno-serial
-Wno-specialParamHiding
-Wno-static-access
-Wno-static-method
-Wno-staticReceiver
-Wno-super
-Wno-suppress
-Wno-switchDefault
-Wno-syncOverride
-Wno-synthetic-access
-Wno-syntheticAccess
-Wno-typeHiding
-Wno-unavoidableGenericProblems
-Wno-unchecked
-Wno-unnecessaryElse
-Wno-unqualifiedField
-Wno-unqualified-field-access
-Wno-unsafe
-Wno-unused
-Wno-unusedAllocation
-Wno-unusedArgument
-Wno-unusedArguments
-Wno-unusedImport
-Wno-unusedImports
-Wno-unusedLabel
-Wno-unusedLocal
-Wno-unusedLocals
-Wno-unusedPrivate
-Wno-unusedThrown
-Wno-unusedTypeArgs
-Wno-uselessTypeCheck
-Wno-varargsCast
-Wno-warningTokenhttps://stackoverflow.com/questions/2057783
复制相似问题