Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Datafile.hh: " error: cannot convert 'long int*' to 'time_t*' " #14

Open
csrabak opened this issue Mar 11, 2019 · 2 comments
Open

Datafile.hh: " error: cannot convert 'long int*' to 'time_t*' " #14

csrabak opened this issue Mar 11, 2019 · 2 comments

Comments

@csrabak
Copy link

csrabak commented Mar 11, 2019

Using gcc (Rev1, Built by MSYS2 project) 8.2.1 20181207 in a MSYS2 environment I get an error which I could circumvent using an '-fpermissive' compile flag for C++, but this one g++ claims is an error.

What was the latest gcc which gri 2.12.23 built sucessfully in a Windows platform?

@dankelley
Copy link
Owner

I'm sorry, but I don't know anything about Windows anymore. I had a machine with that OS for a year or two, back in the 1990s, I think. If gri builds on such machines, it's because of careful coding to the standards of the time, more than testing with an everyday-use machine.

If you state the filename and line number, I can likely make some guesses as to the fix. This looks like it might have been a remnant, because I thought I was using time_t whenever it was the right thing to do.

It's possible someone on this thread uses windows. I lack access to such machines. I am on macos now, and don't even have a real gcc, since that uses llvm (10.0.0).

@csrabak
Copy link
Author

csrabak commented Mar 11, 2019

Dan,
Nothing to feel sorry about!

I'm as well getting back to Windows and just struck that the last gri binary for this platform is 14 years old port available at GNUwin32 utils. . .

Although until last bit has been unbent and last byte polished no final word can be said on the exact reason for the problem, I surmise is not platform dependent but an issue related to the augmented strictness of the compilers we're are developing with.

Historically is was supposed the programmer (at least in C prog lang) knew was doing and the matters related to loosing precision due casting were at most "code smells" or "advanced warnings".

Nowadays, all compiler writers want to protect us from liberties and more than once I've stumbled with old code that recompiled seems to have fired the NYC Fire Departmente during the Orson Wells radio broadcast...!

So, IMNHO before worrying too mucha about Windows, I would get my attention to the current version of gcc (GNU Compiler Collection, as Gri uses C++ as well).

These are the first lines of config.log:
----------8<----------------------------------------------------------------------------------------------------

It was created by gri configure 2.12.23, which was
generated by GNU Autoconf 2.61.  Invocation command line was

  $ ./configure 

## --------- ##
## Platform. ##
## --------- ##

hostname = salada
uname -m = x86_64
uname -r = 2.11.2(0.329/5/3)
uname -s = MINGW64_NT-6.3
uname -v = 2018-11-26 09:22

/usr/bin/uname -p = unknown
/bin/uname -X     = unknown

/bin/arch              = x86_64
/usr/bin/arch -k       = unknown
/usr/convex/getsysinfo = unknown
/usr/bin/hostinfo      = unknown
/bin/machine           = unknown
/usr/bin/oslevel       = unknown
/bin/universe          = unknown

PATH: /mingw64/bin
PATH: /usr/local/bin
PATH: /usr/bin
PATH: /bin
PATH: /c/Windows/System32
PATH: /c/Windows
PATH: /c/Windows/System32/Wbem
PATH: /c/Windows/System32/WindowsPowerShell/v1.0/

------------------------------------------------------------------------------------------>8--------------------

gcc.exe (Rev1, Built by MSYS2 project) 8.2.1 20181207
Copyright (C) 2018 Free Software Foundation, Inc.
This is free software; see the source for copying conditions.  There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.

If we run make without -k the first error stops with the following:

make
Making all in src
make[1]: Entering directory '/c/Users/csrabak/Work/MyProjects/testes/gri-2.12.23/src'
Making all in popt
make[2]: Entering directory '/c/Users/csrabak/Work/MyProjects/testes/gri-2.12.23/src/popt'
make[2]: Nothing to be done for 'all'.
make[2]: Leaving directory '/c/Users/csrabak/Work/MyProjects/testes/gri-2.12.23/src/popt'
make[2]: Entering directory '/c/Users/csrabak/Work/MyProjects/testes/gri-2.12.23/src'
g++ -DDEFAULT_GRI_DIR=\"/mingw64/share/gri/\"  -DPACKAGE_NAME=\"gri\" -DPACKAGE_TARNAME=\"gri\" -DPACKAGE_VERSION=\"2.12.23\" -DPACKAGE_STRING=\"gri\ 2.12.23\" -DPACKAGE_BUGREPORT=\"\" -DPACKAGE=\"gri\" -DVERSION=\"2.12.23\" -DIS_MINGW32=1 -DGRI_IS_BIG_ENDIAN=0 -DSTDC_HEADERS=1 -DHAVE_SYS_TYPES_H=1 -DHAVE_SYS_STAT_H=1 -DHAVE_STDLIB_H=1 -DHAVE_STRING_H=1 -DHAVE_MEMORY_H=1 -DHAVE_STRINGS_H=1 -DHAVE_INTTYPES_H=1 -DHAVE_STDINT_H=1 -DHAVE_UNISTD_H=1 -DHAVE_UNISTD_H=1 -DSTDC_HEADERS=1 -DHAVE_LIBREADLINE=1 -DHAVE_ISNAN=1 -DHAVE_ACOSH=1 -DHAVE_GETCWD=1 -DHAVE_POPEN=1 -DHAVE_MKSTEMP=1 -DHAVE_TMPNAM=1 -DHAVE_TEMPNAM=1 -DHAVE_ACCESS=1 -DHAVE_STAT=1 -DHAVE_STRERROR=1 -DHAVE_GETENV=1 -I.    -Wall -DCPLUSPLUSNEW -fno-strength-reduce -g -O2 -fpermissive -MT gr.o -MD -MP -MF .deps/gr.Tpo -c -o gr.o gr.cc
In file included from gr_coll.hh:37,
                 from gr.hh:69,
                 from gr.cc:41:
CmdFile.hh: In copy constructor 'CmdFile::CmdFile(const CmdFile&)':
CmdFile.hh:47:64: warning: cast from 'const CmdFile*' to 'long unsigned int' loses precision [-fpermissive]
           __FILE__,__LINE__,name.c_str(),(long unsigned int)(&c),(long unsigned int)this);
                                                                ^
CmdFile.hh:47:85: warning: cast from 'CmdFile*' to 'long unsigned int' loses precision [-fpermissive]
           __FILE__,__LINE__,name.c_str(),(long unsigned int)(&c),(long unsigned int)this);
                                                                                     ^~~~
CmdFile.hh: In member function 'CmdFile& CmdFile::operator=(const CmdFile&)':
CmdFile.hh:63:102: warning: cast from 'CmdFile*' to 'long unsigned int' loses precision [-fpermissive]
    printf("%s:%d try to CmdFile operator= null file this %lx\n",__FILE__,__LINE__,(long unsigned int)this);
                                                                                                      ^~~~
CmdFile.hh: In member function 'void CmdFile::set(const char*, FILE*, bool, int, bool)':
CmdFile.hh:75:108: warning: cast from 'CmdFile*' to 'long unsigned int' loses precision [-fpermissive]
    printf("ERROR at %s:%d -- try to CmdFile set null file this %lx\n",__FILE__,__LINE__,(long unsigned int)this);
                                                                                                            ^~~~
In file included from gr_coll.hh:38,
                 from gr.hh:69,
                 from gr.cc:41:
DataFile.hh: In constructor 'DataFile::DataFile()':
DataFile.hh:40:133: warning: cast from 'FILE*' {aka '_iobuf*'} to 'long unsigned int' loses precision [-fpermissive]
     if (superuser() & FLAG_AUT1)printf("    DEBUG: %s:%d construct from cmdFILE  fp= %lx  ",__FILE__,__LINE__,(long unsigned int)(fp));
                                                                                                                                     ^
DataFile.hh:42:136: warning: cast from 'FILE*' {aka '_iobuf*'} to 'long unsigned int' loses precision [-fpermissive]
     if (superuser() & FLAG_AUT1)printf("    DEBUG: %s:%d construct from stdin    fp= %lx  ",__FILE__,__LINE__,(long unsigned int)(stdin));
                                                                                                                                        ^
DataFile.hh:49:124: warning: cast from 'FILE*' {aka '_iobuf*'} to 'long int' loses precision [-fpermissive]
   if (superuser() & FLAG_AUT1)printf(" ... %s:%d  name= '%s'\t fp= %lx  this= %lx\n",__FILE__,__LINE__,name.c_str(),long(fp),long(this));
                                                                                                                            ^
DataFile.hh:49:135: warning: cast from 'DataFile*' to 'long int' loses precision [-fpermissive]
   if (superuser() & FLAG_AUT1)printf(" ... %s:%d  name= '%s'\t fp= %lx  this= %lx\n",__FILE__,__LINE__,name.c_str(),long(fp),long(this));
                                                                                                                                       ^
DataFile.hh: In copy constructor 'DataFile::DataFile(const DataFile&)':
DataFile.hh:59:134: warning: cast from 'const DataFile*' to 'long int' loses precision [-fpermissive]
   if (superuser() & FLAG_AUT1)printf("    DEBUG: %s:%d DataFile(%lx)    name= '%s'\t fp= %lx   this= %lx\n",__FILE__,__LINE__,long(&d),name.c_str(),long(fp),long(this));
                                                                                                                                      ^
DataFile.hh:59:156: warning: cast from 'FILE*' {aka '_iobuf*'} to 'long int' loses precision [-fpermissive]
   if (superuser() & FLAG_AUT1)printf("    DEBUG: %s:%d DataFile(%lx)    name= '%s'\t fp= %lx   this= %lx\n",__FILE__,__LINE__,long(&d),name.c_str(),long(fp),long(this));
                                                                                                                                                            ^
DataFile.hh:59:167: warning: cast from 'DataFile*' to 'long int' loses precision [-fpermissive]
   if (superuser() & FLAG_AUT1)printf("    DEBUG: %s:%d DataFile(%lx)    name= '%s'\t fp= %lx   this= %lx\n",__FILE__,__LINE__,long(&d),name.c_str(),long(fp),long(this));
                                                                                                                                                                       ^
DataFile.hh: In constructor 'DataFile::DataFile(FILE*, const char*, int, DataFile::type, bool)':
DataFile.hh:68:131: warning: cast from 'FILE*' {aka '_iobuf*'} to 'long int' loses precision [-fpermissive]
   if (superuser() & FLAG_AUT1)printf("    DEBUG: %s:%d DataFile(fp= %lx, name= '%s', ...) this= %lx\n",__FILE__,__LINE__,long(a_fp),a_name,long(this));
                                                                                                                                   ^
DataFile.hh:68:149: warning: cast from 'DataFile*' to 'long int' loses precision [-fpermissive]
   if (superuser() & FLAG_AUT1)printf("    DEBUG: %s:%d DataFile(fp= %lx, name= '%s', ...) this= %lx\n",__FILE__,__LINE__,long(a_fp),a_name,long(this));
                                                                                                                                                     ^
DataFile.hh: In destructor 'DataFile::~DataFile()':
DataFile.hh:71:154: warning: cast from 'FILE*' {aka '_iobuf*'} to 'long int' loses precision [-fpermissive]
   if (superuser() & FLAG_AUT1)printf("    DEBUG: %s:%d DataFile::~DataFile() name= '%s'\t fp= %lx   this= %lx\n",__FILE__,__LINE__, name.c_str(), long(fp), long(this));
                                                                                                                                                          ^
DataFile.hh:71:166: warning: cast from 'DataFile*' to 'long int' loses precision [-fpermissive]
   if (superuser() & FLAG_AUT1)printf("    DEBUG: %s:%d DataFile::~DataFile() name= '%s'\t fp= %lx   this= %lx\n",__FILE__,__LINE__, name.c_str(), long(fp), long(this));
                                                                                                                                                                      ^
DataFile.hh: In member function 'DataFile& DataFile::operator=(const DataFile&)':
DataFile.hh:84:154: warning: cast from 'FILE*' {aka '_iobuf*'} to 'long int' loses precision [-fpermissive]
   if (superuser() & FLAG_AUT1)printf("    DEBUG: %s:%d DataFile::operator=   name= '%s'\t fp=  %lx  this= %lx\n",__FILE__,__LINE__, name.c_str(), long(fp), long(this));
                                                                                                                                                          ^
DataFile.hh:84:166: warning: cast from 'DataFile*' to 'long int' loses precision [-fpermissive]
   if (superuser() & FLAG_AUT1)printf("    DEBUG: %s:%d DataFile::operator=   name= '%s'\t fp=  %lx  this= %lx\n",__FILE__,__LINE__, name.c_str(), long(fp), long(this));
                                                                                                                                                                      ^
gr.cc: In function 'void insert_ps_header(FILE*, bool)':
gr.cc:426:8: error: cannot convert 'long int*' to 'time_t*' {aka 'long long int*'}
   time(&sec);
        ^~~~
In file included from gr.cc:33:
C:/msys64/mingw64/x86_64-w64-mingw32/include/time.h:242:43: note:   initializing argument 1 of 'time_t time(time_t*)'
 __TIME_INLINE time_t __cdecl time(time_t *_Time) { return _time64(_Time); }
                                   ~~~~~~~~^~~~~
gr.cc:427:57: error: cannot convert 'long int*' to 'const time_t*' {aka 'const long long int*'}
   fprintf(fp, "%%%%CreationDate: %s", asctime(localtime(&sec)));
                                                         ^~~~
In file included from gr.cc:33:
C:/msys64/mingw64/x86_64-w64-mingw32/include/time.h:239:58: note:   initializing argument 1 of 'tm* localtime(const time_t*)'
 __TIME_INLINE struct tm *__cdecl localtime(const time_t *_Time) { return _localtime64(_Time); }
                                            ~~~~~~~~~~~~~~^~~~~
make[2]: *** [Makefile:402: gr.o] Error 1
make[2]: Leaving directory '/c/Users/csrabak/Work/MyProjects/testes/gri-2.12.23/src'
make[1]: *** [Makefile:422: all-recursive] Error 1
make[1]: Leaving directory '/c/Users/csrabak/Work/MyProjects/testes/gri-2.12.23/src'
make: *** [Makefile:223: all-recursive] Error 1

OTOH I know that time_t being "implementation defined" and MSYS/MSYS2 striving to use Windows libraries can be we are caught in an interesting trap, which older ports eluded, perhaps using a different libc implementation (after of all gri is a command line program).

I don't mind into delving in the issue but would like not to expend time in redundant way if other developers already found this and most importantly the solution to the problem.

Best Regards,

Cesar Rabak

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants