Quantcast

[Beremiz-devel] MatIEC Compiler errors on most recent GCC

classic Classic list List threaded Threaded
5 messages Options
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

[Beremiz-devel] MatIEC Compiler errors on most recent GCC

Beremiz-Devel mailing list
Hi all,

I have a simple PLC application using MatIEC compiler. My Structured Text code goes as input to MatIEC that successfully generates C files for it (POUS.c, POUS.h, LOCATED_VARIABLES.h, Config0.c, Config0.h and Res0.c). I then compile this code with GCC:

g++ -I ./lib -c Config0.c
g++ -I ./lib -c Res0.c
g++ *.cpp *.o -o myplc -I ./lib

Note: I have a sub folder ./lib with all the C libraries that comes with MatIEC code.

This application has been running flawlessly for a long time, even with different Structured Text programs as input. It always compiled fine with no warnings or errors on GCC 4.9.2

The problem is that now I upgraded to Ubuntu 17.04 and it comes with GCC 6.3.0. This version of GCC is giving errors to compile the Config0.c file. I wanted to make sure that both were trying to compile the same code, so I installed Ubuntu 17.04 on a VM and had another old Linux VM with GCC 4.9.2. Both compiling exactly the same code. On the old GCC it compiled without errors or warnings. On GCC 6.3.0 it had the following errors and warnings:

In file included from Config0.c:6:0:
./lib/iec_std_lib.h: In function ‘TIME __time_mul(TIME, LREAL)’:
./lib/iec_std_lib.h:389:22: warning: narrowing conversion of ‘((LREAL)(long int)ns.div_t::rem + ((s_f - (LREAL)s) * (LREAL)1000000000))’ from ‘LREAL {aka double}’ to ‘long int’ inside { } [-Wnarrowing]
         (long)ns.rem + (s_f - s) * 1000000000 };
         ~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~
./lib/iec_std_lib.h: In function ‘TIME __real_to_time(LREAL)’:
./lib/iec_std_lib.h:547:94: warning: narrowing conversion of ‘IN’ from ‘LREAL {aka double}’ to ‘long int’ inside { } [-Wnarrowing]
 static inline TIME   __real_to_time(LREAL IN) {return (TIME){IN, (IN - (LINT)IN) * 1000000000};}
                                                                                              ^
./lib/iec_std_lib.h:547:82: warning: narrowing conversion of ‘((IN - (LREAL)(LINT)IN) * (LREAL)1000000000)’ from ‘LREAL {aka double}’ to ‘long int’ inside { } [-Wnarrowing]
 static inline TIME   __real_to_time(LREAL IN) {return (TIME){IN, (IN - (LINT)IN) * 1000000000};}
                                                                  ~~~~~~~~~~~~~~~~^~~~~~~~~~~~
./lib/iec_std_lib.h: In function ‘STRING __time_to_string(TIME)’:
./lib/iec_std_lib.h:594:42: error: call of overloaded ‘div(long int&, int)’ is ambiguous
     days = div(IN.tv_sec, SECONDS_PER_DAY);
                                          ^
In file included from /usr/include/c++/6/cstdlib:75:0,
                 from /usr/include/c++/6/stdlib.h:36,
                 from ./lib/iec_std_lib.h:40,
                 from Config0.c:6:
/usr/include/stdlib.h:749:14: note: candidate: div_t div(int, int)
 extern div_t div (int __numer, int __denom)
              ^~~
In file included from /usr/include/c++/6/stdlib.h:36:0,
                 from ./lib/iec_std_lib.h:40,
                 from Config0.c:6:
/usr/include/c++/6/cstdlib:233:3: note: candidate: lldiv_t __gnu_cxx::div(long long int, long long int)
   div(long long __n, long long __d)
   ^~~
/usr/include/c++/6/cstdlib:175:3: note: candidate: ldiv_t std::div(long int, long int)
   div(long __i, long __j) { return ldiv(__i, __j); }
   ^~~
In file included from Res0.c:6:0:
./lib/iec_std_lib.h: In function ‘TIME __time_mul(TIME, LREAL)’:
./lib/iec_std_lib.h:389:22: warning: narrowing conversion of ‘((LREAL)(long int)ns.div_t::rem + ((s_f - (LREAL)s) * (LREAL)1000000000))’ from ‘LREAL {aka double}’ to ‘long int’ inside { } [-Wnarrowing]
         (long)ns.rem + (s_f - s) * 1000000000 };
         ~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~
./lib/iec_std_lib.h: In function ‘TIME __real_to_time(LREAL)’:
./lib/iec_std_lib.h:547:94: warning: narrowing conversion of ‘IN’ from ‘LREAL {aka double}’ to ‘long int’ inside { } [-Wnarrowing]
 static inline TIME   __real_to_time(LREAL IN) {return (TIME){IN, (IN - (LINT)IN) * 1000000000};}
                                                                                              ^
./lib/iec_std_lib.h:547:82: warning: narrowing conversion of ‘((IN - (LREAL)(LINT)IN) * (LREAL)1000000000)’ from ‘LREAL {aka double}’ to ‘long int’ inside { } [-Wnarrowing]
 static inline TIME   __real_to_time(LREAL IN) {return (TIME){IN, (IN - (LINT)IN) * 1000000000};}
                                                                  ~~~~~~~~~~~~~~~~^~~~~~~~~~~~
./lib/iec_std_lib.h: In function ‘STRING __time_to_string(TIME)’:
./lib/iec_std_lib.h:594:42: error: call of overloaded ‘div(long int&, int)’ is ambiguous
     days = div(IN.tv_sec, SECONDS_PER_DAY);
                                          ^
In file included from /usr/include/c++/6/cstdlib:75:0,
                 from /usr/include/c++/6/stdlib.h:36,
                 from ./lib/iec_std_lib.h:40,
                 from Res0.c:6:
/usr/include/stdlib.h:749:14: note: candidate: div_t div(int, int)
 extern div_t div (int __numer, int __denom)
              ^~~
In file included from /usr/include/c++/6/stdlib.h:36:0,
                 from ./lib/iec_std_lib.h:40,
                 from Res0.c:6:
/usr/include/c++/6/cstdlib:233:3: note: candidate: lldiv_t __gnu_cxx::div(long long int, long long int)
   div(long long __n, long long __d)
   ^~~
/usr/include/c++/6/cstdlib:175:3: note: candidate: ldiv_t std::div(long int, long int)
   div(long __i, long __j) { return ldiv(__i, __j); }
   ^~~

Apparently there is some overloaded function in MatIEC library that GCC doesn't like. I don't know what is exactly what is causing this, but I'll keep investigating. Any advice will be very helpful.


Thanks!

Thiago Alves

------------------------------------------------------------------------------
Check out the vibrant tech community on one of the world's most
engaging tech sites, Slashdot.org! http://sdm.link/slashdot
_______________________________________________
Beremiz-devel mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/beremiz-devel
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: [Beremiz-devel] MatIEC Compiler errors on most recent GCC

Beremiz-Devel mailing list
I managed to fix this issue on GCC 6.3.0 by typecasting on iec_std_lib.h line 594:

594: days = div((int &)IN.tv_sec, SECONDS_PER_DAY);

It seems that on the newer versions of GCC, the timespec,tv_sec object was changed from int& to long int&, and this was causing issues with the compiler. By just typecasting (int &) the code compiles. I don't know the problems it might cause with the functionality of the program, but apparently it works fine.

On Mon, May 8, 2017 at 3:16 PM, Thiago Rodrigues Alves <[hidden email]> wrote:
Hi all,

I have a simple PLC application using MatIEC compiler. My Structured Text code goes as input to MatIEC that successfully generates C files for it (POUS.c, POUS.h, LOCATED_VARIABLES.h, Config0.c, Config0.h and Res0.c). I then compile this code with GCC:

g++ -I ./lib -c Config0.c
g++ -I ./lib -c Res0.c
g++ *.cpp *.o -o myplc -I ./lib

Note: I have a sub folder ./lib with all the C libraries that comes with MatIEC code.

This application has been running flawlessly for a long time, even with different Structured Text programs as input. It always compiled fine with no warnings or errors on GCC 4.9.2

The problem is that now I upgraded to Ubuntu 17.04 and it comes with GCC 6.3.0. This version of GCC is giving errors to compile the Config0.c file. I wanted to make sure that both were trying to compile the same code, so I installed Ubuntu 17.04 on a VM and had another old Linux VM with GCC 4.9.2. Both compiling exactly the same code. On the old GCC it compiled without errors or warnings. On GCC 6.3.0 it had the following errors and warnings:

In file included from Config0.c:6:0:
./lib/iec_std_lib.h: In function ‘TIME __time_mul(TIME, LREAL)’:
./lib/iec_std_lib.h:389:22: warning: narrowing conversion of ‘((LREAL)(long int)ns.div_t::rem + ((s_f - (LREAL)s) * (LREAL)1000000000))’ from ‘LREAL {aka double}’ to ‘long int’ inside { } [-Wnarrowing]
         (long)ns.rem + (s_f - s) * 1000000000 };
         ~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~
./lib/iec_std_lib.h: In function ‘TIME __real_to_time(LREAL)’:
./lib/iec_std_lib.h:547:94: warning: narrowing conversion of ‘IN’ from ‘LREAL {aka double}’ to ‘long int’ inside { } [-Wnarrowing]
 static inline TIME   __real_to_time(LREAL IN) {return (TIME){IN, (IN - (LINT)IN) * 1000000000};}
                                                                                              ^
./lib/iec_std_lib.h:547:82: warning: narrowing conversion of ‘((IN - (LREAL)(LINT)IN) * (LREAL)1000000000)’ from ‘LREAL {aka double}’ to ‘long int’ inside { } [-Wnarrowing]
 static inline TIME   __real_to_time(LREAL IN) {return (TIME){IN, (IN - (LINT)IN) * 1000000000};}
                                                                  ~~~~~~~~~~~~~~~~^~~~~~~~~~~~
./lib/iec_std_lib.h: In function ‘STRING __time_to_string(TIME)’:
./lib/iec_std_lib.h:594:42: error: call of overloaded ‘div(long int&, int)’ is ambiguous
     days = div(IN.tv_sec, SECONDS_PER_DAY);
                                          ^
In file included from /usr/include/c++/6/cstdlib:75:0,
                 from /usr/include/c++/6/stdlib.h:36,
                 from ./lib/iec_std_lib.h:40,
                 from Config0.c:6:
/usr/include/stdlib.h:749:14: note: candidate: div_t div(int, int)
 extern div_t div (int __numer, int __denom)
              ^~~
In file included from /usr/include/c++/6/stdlib.h:36:0,
                 from ./lib/iec_std_lib.h:40,
                 from Config0.c:6:
/usr/include/c++/6/cstdlib:233:3: note: candidate: lldiv_t __gnu_cxx::div(long long int, long long int)
   div(long long __n, long long __d)
   ^~~
/usr/include/c++/6/cstdlib:175:3: note: candidate: ldiv_t std::div(long int, long int)
   div(long __i, long __j) { return ldiv(__i, __j); }
   ^~~
In file included from Res0.c:6:0:
./lib/iec_std_lib.h: In function ‘TIME __time_mul(TIME, LREAL)’:
./lib/iec_std_lib.h:389:22: warning: narrowing conversion of ‘((LREAL)(long int)ns.div_t::rem + ((s_f - (LREAL)s) * (LREAL)1000000000))’ from ‘LREAL {aka double}’ to ‘long int’ inside { } [-Wnarrowing]
         (long)ns.rem + (s_f - s) * 1000000000 };
         ~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~
./lib/iec_std_lib.h: In function ‘TIME __real_to_time(LREAL)’:
./lib/iec_std_lib.h:547:94: warning: narrowing conversion of ‘IN’ from ‘LREAL {aka double}’ to ‘long int’ inside { } [-Wnarrowing]
 static inline TIME   __real_to_time(LREAL IN) {return (TIME){IN, (IN - (LINT)IN) * 1000000000};}
                                                                                              ^
./lib/iec_std_lib.h:547:82: warning: narrowing conversion of ‘((IN - (LREAL)(LINT)IN) * (LREAL)1000000000)’ from ‘LREAL {aka double}’ to ‘long int’ inside { } [-Wnarrowing]
 static inline TIME   __real_to_time(LREAL IN) {return (TIME){IN, (IN - (LINT)IN) * 1000000000};}
                                                                  ~~~~~~~~~~~~~~~~^~~~~~~~~~~~
./lib/iec_std_lib.h: In function ‘STRING __time_to_string(TIME)’:
./lib/iec_std_lib.h:594:42: error: call of overloaded ‘div(long int&, int)’ is ambiguous
     days = div(IN.tv_sec, SECONDS_PER_DAY);
                                          ^
In file included from /usr/include/c++/6/cstdlib:75:0,
                 from /usr/include/c++/6/stdlib.h:36,
                 from ./lib/iec_std_lib.h:40,
                 from Res0.c:6:
/usr/include/stdlib.h:749:14: note: candidate: div_t div(int, int)
 extern div_t div (int __numer, int __denom)
              ^~~
In file included from /usr/include/c++/6/stdlib.h:36:0,
                 from ./lib/iec_std_lib.h:40,
                 from Res0.c:6:
/usr/include/c++/6/cstdlib:233:3: note: candidate: lldiv_t __gnu_cxx::div(long long int, long long int)
   div(long long __n, long long __d)
   ^~~
/usr/include/c++/6/cstdlib:175:3: note: candidate: ldiv_t std::div(long int, long int)
   div(long __i, long __j) { return ldiv(__i, __j); }
   ^~~

Apparently there is some overloaded function in MatIEC library that GCC doesn't like. I don't know what is exactly what is causing this, but I'll keep investigating. Any advice will be very helpful.


Thanks!

Thiago Alves


------------------------------------------------------------------------------
Check out the vibrant tech community on one of the world's most
engaging tech sites, Slashdot.org! http://sdm.link/slashdot
_______________________________________________
Beremiz-devel mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/beremiz-devel
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: [Beremiz-devel] MatIEC Compiler errors on most recent GCC

Beremiz-Devel mailing list
Hi, Thiago!

This also may be the language issue, I see C++ things in your log, but matiec generates C...

Regards,
Paul Beltyukov

2017-05-09 1:55 GMT+05:00 <[hidden email]>:
I managed to fix this issue on GCC 6.3.0 by typecasting on iec_std_lib.h line 594:

594: days = div((int &)IN.tv_sec, SECONDS_PER_DAY);

It seems that on the newer versions of GCC, the timespec,tv_sec object was changed from int& to long int&, and this was causing issues with the compiler. By just typecasting (int &) the code compiles. I don't know the problems it might cause with the functionality of the program, but apparently it works fine.

On Mon, May 8, 2017 at 3:16 PM, Thiago Rodrigues Alves <[hidden email]> wrote:
Hi all,

I have a simple PLC application using MatIEC compiler. My Structured Text code goes as input to MatIEC that successfully generates C files for it (POUS.c, POUS.h, LOCATED_VARIABLES.h, Config0.c, Config0.h and Res0.c). I then compile this code with GCC:

g++ -I ./lib -c Config0.c
g++ -I ./lib -c Res0.c
g++ *.cpp *.o -o myplc -I ./lib

Note: I have a sub folder ./lib with all the C libraries that comes with MatIEC code.

This application has been running flawlessly for a long time, even with different Structured Text programs as input. It always compiled fine with no warnings or errors on GCC 4.9.2

The problem is that now I upgraded to Ubuntu 17.04 and it comes with GCC 6.3.0. This version of GCC is giving errors to compile the Config0.c file. I wanted to make sure that both were trying to compile the same code, so I installed Ubuntu 17.04 on a VM and had another old Linux VM with GCC 4.9.2. Both compiling exactly the same code. On the old GCC it compiled without errors or warnings. On GCC 6.3.0 it had the following errors and warnings:

In file included from Config0.c:6:0:
./lib/iec_std_lib.h: In function ‘TIME __time_mul(TIME, LREAL)’:
./lib/iec_std_lib.h:389:22: warning: narrowing conversion of ‘((LREAL)(long int)ns.div_t::rem + ((s_f - (LREAL)s) * (LREAL)1000000000))’ from ‘LREAL {aka double}’ to ‘long int’ inside { } [-Wnarrowing]
         (long)ns.rem + (s_f - s) * 1000000000 };
         ~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~
./lib/iec_std_lib.h: In function ‘TIME __real_to_time(LREAL)’:
./lib/iec_std_lib.h:547:94: warning: narrowing conversion of ‘IN’ from ‘LREAL {aka double}’ to ‘long int’ inside { } [-Wnarrowing]
 static inline TIME   __real_to_time(LREAL IN) {return (TIME){IN, (IN - (LINT)IN) * 1000000000};}
                                                                                              ^
./lib/iec_std_lib.h:547:82: warning: narrowing conversion of ‘((IN - (LREAL)(LINT)IN) * (LREAL)1000000000)’ from ‘LREAL {aka double}’ to ‘long int’ inside { } [-Wnarrowing]
 static inline TIME   __real_to_time(LREAL IN) {return (TIME){IN, (IN - (LINT)IN) * 1000000000};}
                                                                  ~~~~~~~~~~~~~~~~^~~~~~~~~~~~
./lib/iec_std_lib.h: In function ‘STRING __time_to_string(TIME)’:
./lib/iec_std_lib.h:594:42: error: call of overloaded ‘div(long int&, int)’ is ambiguous
     days = div(IN.tv_sec, SECONDS_PER_DAY);
                                          ^
In file included from /usr/include/c++/6/cstdlib:75:0,
                 from /usr/include/c++/6/stdlib.h:36,
                 from ./lib/iec_std_lib.h:40,
                 from Config0.c:6:
/usr/include/stdlib.h:749:14: note: candidate: div_t div(int, int)
 extern div_t div (int __numer, int __denom)
              ^~~
In file included from /usr/include/c++/6/stdlib.h:36:0,
                 from ./lib/iec_std_lib.h:40,
                 from Config0.c:6:
/usr/include/c++/6/cstdlib:233:3: note: candidate: lldiv_t __gnu_cxx::div(long long int, long long int)
   div(long long __n, long long __d)
   ^~~
/usr/include/c++/6/cstdlib:175:3: note: candidate: ldiv_t std::div(long int, long int)
   div(long __i, long __j) { return ldiv(__i, __j); }
   ^~~
In file included from Res0.c:6:0:
./lib/iec_std_lib.h: In function ‘TIME __time_mul(TIME, LREAL)’:
./lib/iec_std_lib.h:389:22: warning: narrowing conversion of ‘((LREAL)(long int)ns.div_t::rem + ((s_f - (LREAL)s) * (LREAL)1000000000))’ from ‘LREAL {aka double}’ to ‘long int’ inside { } [-Wnarrowing]
         (long)ns.rem + (s_f - s) * 1000000000 };
         ~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~
./lib/iec_std_lib.h: In function ‘TIME __real_to_time(LREAL)’:
./lib/iec_std_lib.h:547:94: warning: narrowing conversion of ‘IN’ from ‘LREAL {aka double}’ to ‘long int’ inside { } [-Wnarrowing]
 static inline TIME   __real_to_time(LREAL IN) {return (TIME){IN, (IN - (LINT)IN) * 1000000000};}
                                                                                              ^
./lib/iec_std_lib.h:547:82: warning: narrowing conversion of ‘((IN - (LREAL)(LINT)IN) * (LREAL)1000000000)’ from ‘LREAL {aka double}’ to ‘long int’ inside { } [-Wnarrowing]
 static inline TIME   __real_to_time(LREAL IN) {return (TIME){IN, (IN - (LINT)IN) * 1000000000};}
                                                                  ~~~~~~~~~~~~~~~~^~~~~~~~~~~~
./lib/iec_std_lib.h: In function ‘STRING __time_to_string(TIME)’:
./lib/iec_std_lib.h:594:42: error: call of overloaded ‘div(long int&, int)’ is ambiguous
     days = div(IN.tv_sec, SECONDS_PER_DAY);
                                          ^
In file included from /usr/include/c++/6/cstdlib:75:0,
                 from /usr/include/c++/6/stdlib.h:36,
                 from ./lib/iec_std_lib.h:40,
                 from Res0.c:6:
/usr/include/stdlib.h:749:14: note: candidate: div_t div(int, int)
 extern div_t div (int __numer, int __denom)
              ^~~
In file included from /usr/include/c++/6/stdlib.h:36:0,
                 from ./lib/iec_std_lib.h:40,
                 from Res0.c:6:
/usr/include/c++/6/cstdlib:233:3: note: candidate: lldiv_t __gnu_cxx::div(long long int, long long int)
   div(long long __n, long long __d)
   ^~~
/usr/include/c++/6/cstdlib:175:3: note: candidate: ldiv_t std::div(long int, long int)
   div(long __i, long __j) { return ldiv(__i, __j); }
   ^~~

Apparently there is some overloaded function in MatIEC library that GCC doesn't like. I don't know what is exactly what is causing this, but I'll keep investigating. Any advice will be very helpful.


Thanks!

Thiago Alves


------------------------------------------------------------------------------
Check out the vibrant tech community on one of the world's most
engaging tech sites, Slashdot.org! http://sdm.link/slashdot
_______________________________________________
Beremiz-devel mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/beremiz-devel



------------------------------------------------------------------------------
Check out the vibrant tech community on one of the world's most
engaging tech sites, Slashdot.org! http://sdm.link/slashdot
_______________________________________________
Beremiz-devel mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/beremiz-devel
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: [Beremiz-devel] MatIEC Compiler errors on most recent GCC

Beremiz-Devel mailing list

 Hi Thiago,

 I agree with Paul, this _may_ have something to do with the fact that you are
using C++ compiler instead of C. Could you please check again using gcc, and
tell us if the bug remains?


 It also seems to me that the typecast you suggest is using C++ syntax. For C
syntax you may want to use

594: days = div((int)IN.tv_sec, SECONDS_PER_DAY);



  Cheers,

       Mario.
 





On Tuesday 09 May 2017 06:57:46 [hidden email] wrote:

> Hi, Thiago!
>
> This also may be the language issue, I see C++ things in your log, but
> matiec generates C...
>
> Regards,
> Paul Beltyukov
>
> 2017-05-09 1:55 GMT+05:00 <[hidden email]>:
> > I managed to fix this issue on GCC 6.3.0 by typecasting on iec_std_lib.h
> > line 594:
> >
> > 594: days = div((int &)IN.tv_sec, SECONDS_PER_DAY);
> >
> > It seems that on the newer versions of GCC, the timespec,tv_sec object
> > was changed from int& to long int&, and this was causing issues with the
> > compiler. By just typecasting (int &) the code compiles. I don't know
> > the problems it might cause with the functionality of the program, but
> > apparently it works fine.
> >
> > On Mon, May 8, 2017 at 3:16 PM, Thiago Rodrigues Alves <
> >
> > [hidden email]> wrote:
> >> Hi all,
> >>
> >> I have a simple PLC application using MatIEC compiler. My Structured
> >> Text code goes as input to MatIEC that successfully generates C files
> >> for it (POUS.c, POUS.h, LOCATED_VARIABLES.h, Config0.c, Config0.h and
> >> Res0.c). I then compile this code with GCC:
> >>
> >> g++ -I ./lib -c Config0.c
> >> g++ -I ./lib -c Res0.c
> >> g++ *.cpp *.o -o myplc -I ./lib
> >>
> >> Note: I have a sub folder ./lib with all the C libraries that comes with
> >> MatIEC code.
> >>
> >> This application has been running flawlessly for a long time, even with
> >> different Structured Text programs as input. It always compiled fine
> >> with no warnings or errors on GCC 4.9.2
> >>
> >> The problem is that now I upgraded to Ubuntu 17.04 and it comes with GCC
> >> 6.3.0. This version of GCC is giving errors to compile the Config0.c
> >> file. I wanted to make sure that both were trying to compile the same
> >> code, so I installed Ubuntu 17.04 on a VM and had another old Linux VM
> >> with GCC 4.9.2. Both compiling exactly the same code. On the old GCC it
> >> compiled without errors or warnings. On GCC 6.3.0 it had the following
> >> errors and warnings:
> >>
> >> In file included from Config0.c:6:0:
> >> ./lib/iec_std_lib.h: In function ‘TIME __time_mul(TIME, LREAL)’:
> >> ./lib/iec_std_lib.h:389:22: warning: narrowing conversion of
> >> ‘((LREAL)(long int)ns.div_t::rem + ((s_f - (LREAL)s) *
> >> (LREAL)1000000000))’ from ‘LREAL {aka double}’ to ‘long int’ inside { }
> >> [-Wnarrowing]
> >>
> >>          (long)ns.rem + (s_f - s) * 1000000000 };
> >>          ~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~
> >>
> >> ./lib/iec_std_lib.h: In function ‘TIME __real_to_time(LREAL)’:
> >> ./lib/iec_std_lib.h:547:94: warning: narrowing conversion of ‘IN’ from
> >> ‘LREAL {aka double}’ to ‘long int’ inside { } [-Wnarrowing]
> >>
> >>  static inline TIME   __real_to_time(LREAL IN) {return (TIME){IN, (IN -
> >>
> >> (LINT)IN) * 1000000000};}
> >>
> >>                     ^
> >>
> >> ./lib/iec_std_lib.h:547:82: warning: narrowing conversion of ‘((IN -
> >> (LREAL)(LINT)IN) * (LREAL)1000000000)’ from ‘LREAL {aka double}’ to
> >> ‘long int’ inside { } [-Wnarrowing]
> >>
> >>  static inline TIME   __real_to_time(LREAL IN) {return (TIME){IN, (IN -
> >>
> >> (LINT)IN) * 1000000000};}
> >>
> >> ~~~~~~~~~~~~~~~~^~~~~~~~~~~~
> >> ./lib/iec_std_lib.h: In function ‘STRING __time_to_string(TIME)’:
> >> ./lib/iec_std_lib.h:594:42: error: call of overloaded ‘div(long int&,
> >> int)’ is ambiguous
> >>
> >>      days = div(IN.tv_sec, SECONDS_PER_DAY);
> >>      
> >>                                           ^
> >>
> >> In file included from /usr/include/c++/6/cstdlib:75:0,
> >>
> >>                  from /usr/include/c++/6/stdlib.h:36,
> >>                  from ./lib/iec_std_lib.h:40,
> >>
> >>                  from Config0.c:6:
> >> /usr/include/stdlib.h:749:14: note: candidate: div_t div(int, int)
> >>
> >>  extern div_t div (int __numer, int __denom)
> >>  
> >>               ^~~
> >>
> >> In file included from /usr/include/c++/6/stdlib.h:36:0,
> >>
> >>                  from ./lib/iec_std_lib.h:40,
> >>
> >>                  from Config0.c:6:
> >> /usr/include/c++/6/cstdlib:233:3: note: candidate: lldiv_t
> >> __gnu_cxx::div(long long int, long long int)
> >>
> >>    div(long long __n, long long __d)
> >>    ^~~
> >>
> >> /usr/include/c++/6/cstdlib:175:3: note: candidate: ldiv_t std::div(long
> >> int, long int)
> >>
> >>    div(long __i, long __j) { return ldiv(__i, __j); }
> >>    ^~~
> >>
> >> In file included from Res0.c:6:0:
> >> ./lib/iec_std_lib.h: In function ‘TIME __time_mul(TIME, LREAL)’:
> >> ./lib/iec_std_lib.h:389:22: warning: narrowing conversion of
> >> ‘((LREAL)(long int)ns.div_t::rem + ((s_f - (LREAL)s) *
> >> (LREAL)1000000000))’ from ‘LREAL {aka double}’ to ‘long int’ inside { }
> >> [-Wnarrowing]
> >>
> >>          (long)ns.rem + (s_f - s) * 1000000000 };
> >>          ~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~
> >>
> >> ./lib/iec_std_lib.h: In function ‘TIME __real_to_time(LREAL)’:
> >> ./lib/iec_std_lib.h:547:94: warning: narrowing conversion of ‘IN’ from
> >> ‘LREAL {aka double}’ to ‘long int’ inside { } [-Wnarrowing]
> >>
> >>  static inline TIME   __real_to_time(LREAL IN) {return (TIME){IN, (IN -
> >>
> >> (LINT)IN) * 1000000000};}
> >>
> >>                     ^
> >>
> >> ./lib/iec_std_lib.h:547:82: warning: narrowing conversion of ‘((IN -
> >> (LREAL)(LINT)IN) * (LREAL)1000000000)’ from ‘LREAL {aka double}’ to
> >> ‘long int’ inside { } [-Wnarrowing]
> >>
> >>  static inline TIME   __real_to_time(LREAL IN) {return (TIME){IN, (IN -
> >>
> >> (LINT)IN) * 1000000000};}
> >>
> >> ~~~~~~~~~~~~~~~~^~~~~~~~~~~~
> >> ./lib/iec_std_lib.h: In function ‘STRING __time_to_string(TIME)’:
> >> ./lib/iec_std_lib.h:594:42: error: call of overloaded ‘div(long int&,
> >> int)’ is ambiguous
> >>
> >>      days = div(IN.tv_sec, SECONDS_PER_DAY);
> >>      
> >>                                           ^
> >>
> >> In file included from /usr/include/c++/6/cstdlib:75:0,
> >>
> >>                  from /usr/include/c++/6/stdlib.h:36,
> >>                  from ./lib/iec_std_lib.h:40,
> >>
> >>                  from Res0.c:6:
> >> /usr/include/stdlib.h:749:14: note: candidate: div_t div(int, int)
> >>
> >>  extern div_t div (int __numer, int __denom)
> >>  
> >>               ^~~
> >>
> >> In file included from /usr/include/c++/6/stdlib.h:36:0,
> >>
> >>                  from ./lib/iec_std_lib.h:40,
> >>
> >>                  from Res0.c:6:
> >> /usr/include/c++/6/cstdlib:233:3: note: candidate: lldiv_t
> >> __gnu_cxx::div(long long int, long long int)
> >>
> >>    div(long long __n, long long __d)
> >>    ^~~
> >>
> >> /usr/include/c++/6/cstdlib:175:3: note: candidate: ldiv_t std::div(long
> >> int, long int)
> >>
> >>    div(long __i, long __j) { return ldiv(__i, __j); }
> >>    ^~~
> >>
> >> Apparently there is some overloaded function in MatIEC library that GCC
> >> doesn't like. I don't know what is exactly what is causing this, but
> >> I'll keep investigating. Any advice will be very helpful.
> >>
> >>
> >> Thanks!
> >>
> >> Thiago Alves
> >
> > ------------------------------------------------------------
> > ------------------
> > Check out the vibrant tech community on one of the world's most
> > engaging tech sites, Slashdot.org! http://sdm.link/slashdot
> > _______________________________________________
> > Beremiz-devel mailing list
> > [hidden email]
> > https://lists.sourceforge.net/lists/listinfo/beremiz-devel

------------------------------------------------------------------------------
Check out the vibrant tech community on one of the world's most
engaging tech sites, Slashdot.org! http://sdm.link/slashdot
_______________________________________________
Beremiz-devel mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/beremiz-devel
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: [Beremiz-devel] MatIEC Compiler errors on most recent GCC

Beremiz-Devel mailing list
On 17-05-09 10:31, [hidden email] wrote:
>
>  Hi Thiago,
>
>  I agree with Paul, this _may_ have something to do with the fact that you are
> using C++ compiler instead of C. Could you please check again using gcc, and
> tell us if the bug remains?

I use gcc 6.3.0 (C frontend) as my default compiler since it's in
Debian testing (since 2017-01-30). I've not seen this issue.


>  It also seems to me that the typecast you suggest is using C++ syntax. For C
> syntax you may want to use
>
> 594: days = div((int)IN.tv_sec, SECONDS_PER_DAY);
>
>
>
>   Cheers,
>
>        Mario.

--
Best regards,
Andrey Skvortsov



------------------------------------------------------------------------------
Check out the vibrant tech community on one of the world's most
engaging tech sites, Slashdot.org! http://sdm.link/slashdot
_______________________________________________
Beremiz-devel mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/beremiz-devel

signature.asc (849 bytes) Download Attachment
Loading...