VC ++:为什么将int32_t与uint64_t相比较比与uint32_t相比较需要更高的警告级别?

时间:2019-03-28 14:17:01

标签: c++ visual-c++ visual-studio-2017

package com.gc.dev;

import com.realobjects.pdfreactor.webservice.client.Configuration;
import com.realobjects.pdfreactor.webservice.client.PDFreactor;
import com.realobjects.pdfreactor.webservice.client.PDFreactorWebserviceException;
import com.realobjects.pdfreactor.webservice.client.Result;
import java.io.FileOutputStream;
import java.io.IOException;
import java.text.DateFormat;
import java.text.SimpleDateFormat;
import java.util.Date;

public class PDFReactorTest {
    public static void main(String[] args) {

        DateFormat dateFormat = new SimpleDateFormat("yyyy/MM/dd HH:mm:ss");
        Date date = new Date();
        String timeStamp = dateFormat.format(date);
        // Create new PDFreactor instance
        PDFreactor pdfReactor = new PDFreactor("http://localhost:9423/service/rest");

        // Create a new configuration object
        Configuration config = new Configuration()
       // Specify the input document for Mac systems (adapt path if necessary)            .setDocument("file:///ro/config/html/test/print_sc_font.html")
                // Enable javaScriptSettings

                .setJavaScriptMode(Configuration.JavaScriptMode.ENABLED)
                // Set an appropriate log level
                .setLogLevel(Configuration.LogLevel.DEBUG)
                // Sets the title of the created PDF
                .setTitle("Demonstration of PDFreactor Java API")
                // Sets the author of the created PDF
                .setAuthor("Myself")
                // Enables links in the PDF document.
                .setAddLinks(true)
                // Enable bookmarks in the PDF document
                .setAddBookmarks(true)
                // Set some viewer preferences
                .setViewerPreferences(
                        Configuration.ViewerPreferences.FIT_WINDOW,
                     Configuration.ViewerPreferences.PAGE_MODE_USE_THUMBS)

                // Add user style sheets

                .setUserStyleSheets(

                        new Configuration.Resource().setContent("@page {" +

                                "@top-center {" +

                                "content: 'PDFreactor Java API demonstration';" +

                                "}" +

                                " @bottom-center {" +

                                "content: \"Created on " + timeStamp + "\";" +

                                "}" +

                                "}"),

                        new Configuration.Resource().setUri("common.css"));

        FileOutputStream fos = null;
        try {
            // Render document and save result to result
            Result result = pdfReactor.convert(config);
            if (result != null) {
                byte[] pdf = result.getDocument();
                //Save the pdf at the desired location
                fos = new FileOutputStream("result.pdf");
                fos.write(pdf);
                fos.close();
            }
        } catch (PDFreactorWebserviceException exception) {
            Result result = exception.getResult();
            System.err.println(result.getError());

        } catch (Exception e) {

        } finally {
            if (fos != null) {
                try {
                    fos.close();
                } catch (IOException e) {
                }

            }

        }
    }

}

由于相同的原因,两个比较都包含相同的错误,但是VC ++编译器仅在/ Wall下警告第二个错误,而在/ W3下警告第一个错误(每次都相同,但警告代码不同)。对于看似相同的问题,使用两种不同的代码和警告级别是否有特定的原因?

0 个答案:

没有答案