Trolltech Home | Qt-interest Home | Recent Threads | All Threads | Author | Date
All threads index page 1

Qt-interest Archive, May 2008
Re: AW: using 32bit and 64bit QT

Pages: Prev | 1 | 2 | Next

Message 16 in thread

Hi,

> q:\qt\64_static\include\qtcore\../../src/corelib/concurrent/qtconcurrentiteratekernel.h(71) 
> : warning C4512: 'QtConcurrent::BlockSizeManager': Zuweisungsoperator 
> konnte nicht generiert werden

What does line 71 look like in your copy of qtconcurrentiteratekernel.h?

> [...]
> Appearantly the assignment operator for QtConcurrent::BlockSizeManager 
> could not be created.

Indeed, but I'm not sure why the assignment operator is needed.

Which warning level are you using in Visual Studio?

-- 
 [ signature omitted ] 

Message 17 in thread

> Von: Dimitri
> Hi,
> 
> >
> q:\qt\64_static\include\qtcore\../../src/corelib/concurrent/qtconcurrentiteratekernel.h(71) 
> > : warning C4512: 'QtConcurrent::BlockSizeManager': Zuweisungsoperator 
> > konnte nicht generiert werden
> 
> What does line 71 look like in your copy of qtconcurrentiteratekernel.h?
> 
> > [...]
> > Appearantly the assignment operator for QtConcurrent::BlockSizeManager 
> > could not be created.
> 
> Indeed, but I'm not sure why the assignment operator is needed.
> 
> Which warning level are you using in Visual Studio?
> 
It's warning level 4 which is just needed when you want to get hundreds of useless warnings... If someone really needs a warning from level4 it should be explicitly enabled instead simply using -W4.


Christian
-- 
 [ signature omitted ] 

Message 18 in thread

Yes, we always compile on the highest warning level to keep our code clean,
and especially when developing for multiple platforms the compiler does 
point
out problems in the code which will break the build on other platforms 
for example.

I recommend the book
*C++ Coding Standards: 101 Rules, Guidelines, and Best Practices
by Herb Sutter

*Its offers excellent guidelines about what to do and what not to do when
coding C++, and why.

As the warning I reported is the only warning I currently get in the Qt 
libraries
with the VC8 compiler at Warning Level IV it should be fixed,
I will enter a bug report on that.

- DavidF

Christian Ehrlicher wrote:
>> Von: Dimitri
>> Hi,
>>
>>     
>> q:\qt\64_static\include\qtcore\../../src/corelib/concurrent/qtconcurrentiteratekernel.h(71) 
>>     
>>> : warning C4512: 'QtConcurrent::BlockSizeManager': Zuweisungsoperator 
>>> konnte nicht generiert werden
>>>       
>> What does line 71 look like in your copy of qtconcurrentiteratekernel.h?
>>
>>     
>>> [...]
>>> Appearantly the assignment operator for QtConcurrent::BlockSizeManager 
>>> could not be created.
>>>       
>> Indeed, but I'm not sure why the assignment operator is needed.
>>
>> Which warning level are you using in Visual Studio?
>>
>>     
> It's warning level 4 which is just needed when you want to get hundreds of useless warnings... If someone really needs a warning from level4 it should be explicitly enabled instead simply using -W4.
>
>
> Christian
>   

--
 [ signature omitted ] 

Message 19 in thread

One workaround to allow maximum warnings on your own code without
hundreds of lines of spew from Qt is to use the pragma directive to
change the warning level around Qt includes, like so:

#pragma warning(push,1)
#include <QWidget>
#include <QSet>
...
#pragma warning(pop)

-- 
 [ signature omitted ] 

Message 20 in thread

Thats a good solution, better to keep the Warning level on the highest,
lowering it specifically where warnings cannot easily be avoided.

Cheers,
- DavidF

Andrew Medico wrote:
> One workaround to allow maximum warnings on your own code without
> hundreds of lines of spew from Qt is to use the pragma directive to
> change the warning level around Qt includes, like so:
>
> #pragma warning(push,1)
> #include <QWidget>
> #include <QSet>
> ...
> #pragma warning(pop)
>
>   

--
 [ signature omitted ] 

Message 21 in thread

RE below and:

> Yes, we always compile on the highest warning level to keep our code clean,
> and especially when developing for multiple platforms the compiler does 
> point out problems in the code which will break the build on other platforms 
> for example.

I'm working on linux with many header files I don't control. However, I 
also want to
compile with the highest warning level possible. I use a small(ish) perl 
script (attached)
and a custom filter file which contains entries like this:

# The following patterns are perl regular expressions
#
# If the last character of a line is backslash, the pattern is continued
# on the next line.
#
# put more general patterns after more specific patterns
#
#
(^/\S*?/include/QtCore/qtconcurrentresultstore.h: At global scope:\n)?\
^/\S*?/include/QtCore/qtconcurrentresultstore.h:\d+: warning: prefix\
'QtConcurrent::ResultIteratorBase\
QtConcurrent::ResultIteratorBase::operator\+\+\(\)' should return\
'QtConcurrent::ResultIteratorBase&'
#
# various inline problems (note backslashes at end of lines)
#
^/\S*?/include/icmAPI/\S*?: In ((copy )?constructor|member function) 
‘.+?’:\n\
^/\S*?/include/icmAPI/\S*?: warning: inlining failed in call to ‘.+?’:\
--param max-inline-insns-single limit reached\n\
\S+?: warning: called from here
...

to do my compiles something like this:

g++ -MT Depends -MD -MF .dep/FsOaObj.cpp.dep -c -Wall -Wextra 
-Wcast-align -Wcast-qual -Wconversion -Wdeprecated-declarations 
-Wdisabled-optimization -Wfloat-equal -Winline 
-Wmissing-format-attribute -Wmultichar -Wno-long-long 
-Wno-system-headers -Wpacked -Wparentheses -Wpointer-arith 
-Wredundant-decls -Wshadow -Wswitch -Wundef -Wunknown-pragmas -Wunused 
-Wwrite-strings -Wabi -Wdeprecated -Wnon-template-friend 
-Wnon-virtual-dtor -Wold-style-cast -Woverloaded-virtual 
-Wpmf-conversions -Wreorder -Wreturn-type -Wsynth -ansi -Wsign-compare 
-Weffc++ -Wsign-promo -Wctor-dtor-privacy -Wstrict-null-sentinel 
-Wformat=2 -Winit-self -Wmissing-include-dirs -Wswitch-default 
-Wmissing-field-initializers -Wnormalized=nfc -Wcomment -std=c++98 
-D_FILE_OFFSET_BITS=64 -D_LARGEFILE_SOURCE -g -rdynamic 
-DICM_DEBUG_ENABLE -DQT_THREAD_SUPPORT 
-I/usr/local/Trolltech/latest44/include/QtCore 
-I/usr/local/Trolltech/latest44/include/QtGui 
-I/usr/local/Trolltech/latest44/include/QtScript 
-I/usr/local/Trolltech/latest44/include/QtNetwork 
-I/home/peter/downloads/software/si2/latest/include/oa 
-I/opt/icmanage/TOOLROOT/2.2/include/mysql 
-I/opt/icmanage/TOOLROOT/2.2/include -pedantic -I../browser 
-I../icmqtapp -I../libicm -I/opt/icmanage/TOOLROOT/2.2/include/icmAPI 
-I/opt/icmanage/TOOLROOT/2.2/include/roglib -I. 
-I/opt/icmanage/TOOLROOT/2.2/include/p4api 
-I/usr/local/Trolltech/latest44/include 
-I/home/peter/downloads/software/si2/latest/include \
-o ../filesys/Debug/FsOaObj.o FsOaObj.cpp > 
../filesys/Debug/FsOaObj.o.c++out 2>&1 ; status=$?
compileFilter -eFile ../g++suppression.re ../filesys/Debug/FsOaObj.o.c++out

So I can see that my code is total clean but not see a bunch of problems 
that I have no control over.

David Forstenlechner wrote:
> Thats a good solution, better to keep the Warning level on the highest,
> lowering it specifically where warnings cannot easily be avoided.
>
> Cheers,
> - DavidF
>
> Andrew Medico wrote:
>> One workaround to allow maximum warnings on your own code without
>> hundreds of lines of spew from Qt is to use the pragma directive to
>> change the warning level around Qt includes, like so:
>>
>> #pragma warning(push,1)
>> #include <QWidget>
>> #include <QSet>
>> ...
>> #pragma warning(pop)
>>
>
> -- 
> To unsubscribe - send a mail to qt-interest-request@xxxxxxxxxxxxx with 
> "unsubscribe" in the subject or the body.
> List archive and information: http://lists.trolltech.com/qt-interest/
>
#!/bin/sh
#!/bin/sh
#!/bin/sh -- # perl
# the double line above (with -x below) so it works on both NT tcsh and unix
eval 'exec perl -x -w -S $0 ${1+"$@"}'
    if 0;

use strict;
use English;
BEGIN {
          $WARNING = 1; # same as using -w in eval exec above
          unshift(@INC,"/users/peter/lib/perl");
      }

our($usageStr) =
    "compileFilter [-e <pattern>] [-eFile <reListFile>] \\\n"
  . "              [-files|-f <fileListFile>] ... [-endPad] \\\n"
  . "              [-i] [-debug [#] ] [-debugPattern #] \\\n"
  . "              [<pattern>] [ <file> | - ] ...\n"
  . "compileFilter [-man] [-help]\n";

sub man_page
{
    print <<'END_OF_MAN_1';

compileFilter: perl program that filters compiler output

END_OF_MAN_1
    print STDOUT "$usageStr";

    print <<'END_OF_MAN_2';

compileFilter reads files and filters out lines that match <pattern>.
File can be "-" in which case stdin will be read.

Note that as a special case, lines that contain "error: " are never
filtered out.

The patterns provided must match to the end of a line unless -endPad
is provided.

OPTIONS

-debug [#]
        Print debugging info. If no number or if it's 1, print patterns.
        If number is 2, show whether a pattern matches file for each pattern 
        (without doing substitutions.) If number is 3, if the pattern matches
        at subsitution time, show diff as each pattern is applied.

-debugPattern pattern#
        Print out information about how much of pattern# matches the file.
        This can be useful when dealing with large, complex patterns.

-e <pattern>
        Use this if pattern has leading "-".

-eFile <patternFilePath>
        Read a list of patterns out of <filePath>.  Comments can be added in 
        the file by starting a line with #. NOTE: patterns can be continued 
        to the next line by placing a backslash at the end of a line. See
        EXAMPLE below.

-files <fileListFile>
-f     <fileListFile>
        Read a list of files to filter from fileListFile. This option can
        be repeated.

-endPad
        Add .* to end of filter patterns.

-i
        Case insensitive (not currently supported)

-verbose
        Produce more stderr output. Do things like printing out the name
        of the file being processed.

-man
        This output.
        compileFilter -man | more
        might be helpful

-help
        Usage string.

EXAMPLE

Example -eFile file icManager/qt4/g++suppression.re:
...
#
# has virtual functions but non-virtual destructor
# ------------------------------------------------
#
(^/\S*?/include/oa/\S*?: In instantiation of â??.+?â??:\n\
^/\S*:\d+:   instantiated from here\n)?\
^/\S*/include/oa/\S*?:\d+: warning: â??.+?â??\
 has virtual functions but non-virtual destructor
...


SEE ALSO
        vi `which compileFilter`

END_OF_MAN_2
    exit();
}

sub usage
{
    print STDERR "$usageStr";
    exit();
}

our($TMP) = "/tmp/compileFilter.$$";

our($brief) = 1;
our(@patterns) = ();
our($patternsCount) = 0;
our($eFile) = "";
our(@fileListFiles) = ();
our(@files) = ();
our($filecount) = 0;
our($endPad) = 0;
our($case_insensitive) = 0;
our($debug) = "no";
our($debugPattern) = -1;

our($arg);
while ( ($arg = shift(@ARGV)) )
{
    if ( $arg =~ /^-debug$/ )
    {
        if ( $ARGV[0] =~ /\d+/ ) {
            $debug = "y" x $ARGV[0];
            print STDERR "debug: $debug\n";
            shift(@ARGV);
        } else {
            if ( $debug =~ /no/ ) {
                $debug = "y";
            } else {
                $debug = "y$debug";
            }
        }
    }
    elsif ( $arg =~ /^-debugPattern$/ )
    {
        if ( $ARGV[0] =~ /\d+/ ) {
            $debugPattern = $ARGV[0];
            print STDERR "debugPattern # $debugPattern\n";
            shift(@ARGV);
        } else {
            print STDERR "-debugPattern requires a pattern number\n";
            usage();
        }
    }
    elsif ( $arg =~ /^-e$/ )
    {
        $patterns[$patternsCount++] = shift(@ARGV);
    }
    elsif ( $arg =~ /^-eF(ile)?$/ )
    {
        $eFile = shift(@ARGV);
    }
    elsif (    $arg =~ /^-files$/
            || $arg =~ /^-f$/ )
    {
        $fileListFiles[$#fileListFiles+1] = shift(@ARGV);
    }
    elsif ( $arg =~ /^-endPad$/ )
    {
        $endPad = 1;
    }
    elsif ( $arg =~ /^-i$/ )
    {
        $case_insensitive = 1;
        print STDERR "-i (insensitive) not currently supported\n";
    }
    elsif ( $arg =~ /^-m(an)?$/ )
    {
        &man_page();
    }
    elsif ( $arg =~ /^-h(elp)?$/ )
    {
        &usage();
    }
    elsif ( $arg =~ /^-v(erbose)?$/ )
    {
        $brief = 0;
    }
    elsif ( $arg =~ /^-$/ )
    {
        $files[$filecount++] = "-";
    }
    elsif ( $arg =~ /^-/ )
    {
        print STDERR "Unknown option $arg. Bailing.\n";
        &usage;
    }
    else
    {
        if ( $patternsCount == 0 && $eFile eq "" )
        {
            $patterns[$patternsCount++] = $arg;
        }
        else
        {
            $files[$filecount++] = $arg;
        }
    }
}
if ( $eFile ne "" )
{
    # process regular expressions file
    if ( ! open(FILE,"<$eFile") )
    {
        print STDERR "Can't open $eFile for read: $!\n";
        usage();
    }
    # grab the filter regular expressions from the file
    my($line);
    while ( $line = <FILE> )
    {
        chomp($line);
        $line =~ s/\r//;
        my($pattern) = $line;
        if ( $line =~ /^\s*#/ || $line =~ /^\s*$/ ) {
            next; # skip lines that start with # (comments) or are blank
        }
        while ( $pattern =~ /\\$/ ) { # join lines that end in \
            $pattern =~ s/\\$//;
            $line = <FILE>; 
            if ( defined($line) ) {
                chomp($line); $line =~ s/\r//;
                $pattern .= $line;
            } else {
                last;
            }
        }
        # replace fancy single quotes with ascii single quotes
        $pattern =~ s/â??/'/g;
        $pattern =~ s/â??/'/g;
        if ( $debug =~ /y/ ) {
            print STDERR "pattern[" . ($patternsCount+1) . "] '$pattern'\n";
        }
        $patterns[$patternsCount++] = $pattern;
    }
    close(FILE);
}
if ( $#fileListFiles >= 0 )
{
    # process file list files
    my($i);
    for ( $i = 0 ; $i <= $#fileListFiles ; $i++ )
    {
        if ( ! open(FILE,"<$fileListFiles[$i]") )
        {
            print STDERR "Can't open $fileListFiles[$i] for read: $!\n";
            usage();
        }
        my($file);
        while ( $file = <FILE> )
        {
            chomp($file);
            if ( -e $file && ! -r $file )
            {
                print STDERR "Can't read file '$file'\n";
                next;
            }
            elsif ( ! -e $file )
            {
                print STDERR "'$file' not found\n";
                next;
            }

            $files[$filecount++] = $file;
        }
        close(FILE);
    }
}

if ( $filecount <= 0 )
{
    print STDERR "compileFilter: no files to process, bailing.\n";
    usage();
    exit(1);
}

use FileHandle;
STDOUT->autoflush(1);

# subroutines
#------------

sub doFile($);
sub showMatches($); # debug: show which patterns match without doing the sub.
sub writeBufOut($$); # writeBufOut($fileBuf,"$TMP.before");
# read all of $filePath and return it in a scalar variable.
sub readFileIntoVar($); 
sub doDebugPattern($$$); # doDebugPattern(\$fileBuf,$pattern,$patNum);
sub doDebugPatternWhere($$); # doDebugPatternWhere($rFileBuf,$shorter);

########
# Main #
########

autoflush STDOUT;

our($startTime) = time();
our($i);
for ( $i = 0 ; $i < $filecount ; $i++ )
{
    if ( ! $brief )
    {
        print STDERR "compileFilter: ", $files[$i], "\n";
    }
    if ( $filecount == 1 ) {
        print STDOUT "See $files[$i] for unfiltered compiler output\n";
    }
    doFile($files[$i]);
}

if ( -f  "$TMP.before" ) {
    my($cmd) = "rm -f $TMP.before $TMP.after";
    print STDERR "cmd: $cmd\n";
    my($rtn) = system($cmd);
}
our($endTime) = time();
if ( $filecount == 1 ) {
    my($extra) = "";
    if ( $endTime > $startTime ) {
        $extra = "(" . ($endTime-$startTime) . " seconds)\n";
    }
    print STDOUT "$extra"
}

exit 0;

###############
# subroutines #
###############

sub doFile($)
{
    my($file) = @_;

    my($fileBuf) = readFileIntoVar($file);
    # replace fancy single quotes with ascii single quotes
    $fileBuf =~ s/â??/'/g;
    $fileBuf =~ s/â??/'/g;

    if ( $debug =~ /yy/ ) {
        showMatches($fileBuf);
    }
    # special: grab all lines that contain "error: "
    my(@errMatches) = $fileBuf =~ m/^.*\berror:\s.*$/mg;
    my($i);
    for ( $i = 0 ; $i < $patternsCount ; $i++ ) {
        my($pattern) = $patterns[$i];

        if ( $debugPattern - 1  == $i ) {
            doDebugPattern(\$fileBuf,$pattern,$debugPattern);
        }

        if ( $endPad ) {
            # add ^.* and .*\n to pattern so that whole lines are removed
            $pattern = "^.*$pattern.*\\n";
        } else {
            # add ^.* and \n to pattern so that whole lines are removed
            $pattern = "^.*$pattern\\n";
        }
        my($match) = 0;
        if ( $debug =~ /yy/ ) { 
            print STDERR "pattern: '$pattern'\n"; 
            if ( $fileBuf !~ /$pattern/m ) {
                print STDERR "    no matches\n";
                $match = 0;
            } else {
                print STDERR "    MATCHES\n";
                $match = 1;
            }
        }
        if ( $match && $debug =~ /yyy/ ) {
            writeBufOut($fileBuf,"$TMP.before");
        }
        # do the filtering
        #--------------------------
        $fileBuf =~ s/$pattern//mg;
        #--------------------------

        if ( $match && $debug =~ /yyy/ ) {
            writeBufOut($fileBuf,"$TMP.after");
            my($cmd) = "diff $TMP.before $TMP.after";
            print STDERR "diff out:\n";
            my($rtn) = system($cmd);
        }
    }
    if ( $debug =~ /y/ || $debugPattern != -1 ) {
        print "\nStart of output:\n";
    }
    my($extraHilite) = 0;
    my($fileBufLen) = length($fileBuf);
    if ( $filecount > 1 && ( $fileBufLen != 0 || $#errMatches > -1) ) {
        $extraHilite = 1;
        print "\n$file\n";
    } elsif ( $filecount > 1 ) {
        print "$file\n";
    }
    # do special "error: " handling
    if (    $#errMatches > -1 
         && ( $fileBufLen == 0 || $fileBuf !~ /error:/ ) ) {
        print "compileFilter: special 'error: ' matches:\n";
        for ( $i = 0 ; $i <= $#errMatches ; $i++ ) {
            print "    $errMatches[$i]\n";
        }
        print "compileFilter: special 'error: ' matches END.\n";
    }
    print $fileBuf;
    if ( $extraHilite ) {
        print "\n";
    }
}

# writeBufOut($fileBuf,"$TMP.before");
sub writeBufOut($$)
{
    my($fileBuf,$filePath) = @_;

    if ( ! open(FILEOUT,">$filePath") ) {
        print STDERR "Can't open $filePath for write: $!\n";
        return;
    }
    print FILEOUT $fileBuf;
    close FILEOUT;
}

# debug: show which patterns match without doing the sub.
sub showMatches($)
{
    my($fileBuf) = @_;
    print STDERR "\nshowMatches START\n";
    my($i);
    for ( $i = 0 ; $i < $patternsCount ; $i++ ) {
        my($pattern) = $patterns[$i];
        if ( $endPad ) {
            # add ^.* and .*\n to pattern so that whole lines are removed
            $pattern = "^.*$pattern.*\\n";
        } else {
            # add ^.* and \n to pattern so that whole lines are removed
            $pattern = "^.*$pattern\\n";
        }
        print STDERR "pattern: '$pattern'\n"; 
        if ( $fileBuf !~ /$pattern/m ) {
            print STDERR "    no matches\n";
        } else {
            print STDERR "    matches\n";
        }
    }
    print STDERR "showMatches END\n\n";
}
#     ---------------
# sub readFileIntoVar($filePath); 
#     ---------------
#
# read all of $filePath and return it in a scalar variable.
#
sub readFileIntoVar($)
{
    my($filePath) = @_;

    my($filesize) = -s $filePath;

    if ( ! open(INFILE,"<$filePath") ) {
        print STDERR "Can't open $filePath for read: $!\n";
        return undef;
    }

    # read the file into a buffer
    my($filebuf);
    my($readCount);
    if ( ($readCount=read(INFILE,$filebuf,$filesize)) != $filesize ) {
        print STDERR
        "Couldn't read $filesize bytes from $filePath. got $readCount: $!\n";
    }
    close(INFILE);

    return $filebuf;
}

#
# doDebugPattern(\$fileBuf,$pattern,$patPos);
#
sub doDebugPattern($$$)
{
    my($rFileBuf,$pattern,$patNum) = @_;

    my($patternLen) = length($pattern);
    print STDERR "### doDebugPattern with pattern:\n"
               . "$pattern\n"
               . "### length: $patternLen\n"; 
    if ( ${$rFileBuf} =~ /$pattern/m ) {
        print STDERR "### Pattern matches without shortening\n";
        doDebugPatternWhere($rFileBuf,$pattern);
        return;
    }
    my($foundLongest) = 0;
    my($lastGoodPat) = $pattern;
    my($lastGoodPatLen) = $patternLen;
    for ( $i = ($patternLen - 1) ; $i > 0 && ! $foundLongest ; $i-- ) {
        my($shorter) = substr($pattern,0,$i);
        if ( length($shorter) != $i ) {
            print STDERR "ASSERT in doDebugPattern\n";
        }
        eval {
            if ( ${$rFileBuf} =~ /$shorter/m ) {
                #my($space) = " " x ($i-1);
                print STDERR 
                  "### pattern $patNum MATCHES at subPatLen $i\n"
                . "$pattern\n"
                . "$shorter<-HERE\n"
                . "### Next longer legal regExp (length $lastGoodPatLen) is:\n"
                . "$lastGoodPat\n";
                $foundLongest = 1;
                doDebugPatternWhere($rFileBuf,$shorter);
            #} else {
            #    print STDERR ".";
            }
        }; # eval {} (eval block) is the equivalent of try { stuff }
        if ( $EVAL_ERROR ) {
            if ( $EVAL_ERROR !~ /in regex/ ) {
                print STDERR 
                      "### doDebugPattern: got EVAL_ERROR '$EVAL_ERROR'\n";
                $lastGoodPatLen = $i+1;
                $lastGoodPat = $shorter;
            }
        } else {
            $lastGoodPatLen = $i+1;
            $lastGoodPat = $shorter;
        }
    }
}
# doDebugPatternWhere($rFileBuf,$shorter);
sub doDebugPatternWhere($$)
{
    my($rFileBuf,$pattern) = @_;
    my($matches) = 0;
    pos(${$rFileBuf}) = 0;
    while ( ${$rFileBuf} =~ /($pattern)/mg ) {
    #while ( ${$rFileBuf} =~ /$pattern/mg ) {
        $matches++;
        #${$rFileBuf} =~ /($pattern)/m;
        my($matchStr) = $1;
        my($matchIdx) = pos(${$rFileBuf});
        my($matchLen) = length($matchStr);
        $matchIdx -= $matchLen;
        print STDERR "### At char $matchIdx for $matchLen chars: matchStr:\n"
                   . "'$matchStr'\n";
    }
    if ( $matches == 0 ) {
        print STDERR "### doDebugPatternWhere didn't find any matches\n";
    }
}