Code Monkey home page Code Monkey logo

Comments (12)

russkel avatar russkel commented on May 19, 2024

Is there a reason size_t is being redefined?

from zip.

kuba-- avatar kuba-- commented on May 19, 2024

Thanks @russkel - I'll take a look.

It was added in commit: 635ef1d

for 64-bit Windows:

// 64-bit Windows is the only mainstream platform
// where sizeof(long) != sizeof(void*)

It's not a problem with size_t but with redefined ssize_t
If we have ssize_t one of

_SSIZE_T_DEFINED
_SSIZE_T_DEFINED_
_SSIZE_T
_SSIZE_T_
__ssize_t_defined

should be defined. I'll take a look what GCC 9.X. defines.

BTW. Alpine uses musl instead of libc, so I'll have to take a look into this particular distro.

from zip.

kuba-- avatar kuba-- commented on May 19, 2024

Looks adding __DEFINED_ssize_t (which is what musl has) to https://github.com/kuba--/zip/blob/master/src/zip.h#L22 may solve the problem but I'll have to double check it.

from zip.

kuba-- avatar kuba-- commented on May 19, 2024

@russkel - I was able to compile this library on Alpine with gcc 9.2.0, without any problems.
Anyway, just in case I pushed PR: https://github.com/kuba--/zip/pull/111/files
which IMO should fix the potential issue. It just checks/defines another __DEFINED_ssize_t which is used by gcc on Alpine.
PTAL if it works for you

from zip.

kuba-- avatar kuba-- commented on May 19, 2024

@russkel Please feel free to reopen, if the issue still happens.
I'm gonna release a new version with the fix

from zip.

russkel avatar russkel commented on May 19, 2024

hi @kuba-- thanks for this. I haven't had a chance to test it yet but I will later this evening and will report back! Thanks again for quick fix.

from zip.

russkel avatar russkel commented on May 19, 2024

@kuba-- 👍 compiling fine. Thanks for the fix.

from zip.

randomMesh avatar randomMesh commented on May 19, 2024

Hi,

i try to compile latest ASSIMP (which uses zip) on FreeBSD 12.1 32Bit with GCC 9.2.0 and there still is an error regarding typedef redefinition:

[ 65%] Building C object code/CMakeFiles/assimp.dir/__/contrib/zip/src/zip.c.o
In file included from /home/foo/development/libs/assimp/contrib/zip/src/zip.c:39:

/home/foo/development/libs/assimp/contrib/zip/src/zip.h:31:14: error: typedef redefinition with different types ('long' vs '__ssize_t' (aka 'int'))

typedef long ssize_t; /* byte count or error */
             ^

/usr/include/sys/types.h:206:19: note: previous definition is here
typedef __ssize_t       ssize_t;
                        ^

1 error generated.
*** Error code 1

I see that @kimkulling added your fix to the master branch last year, but this doesn't seem to work on FreeBSD. What should i do?

from zip.

kuba-- avatar kuba-- commented on May 19, 2024

@randomMesh - I'll take a look on define pre-proc. in freebsd library and update zip.c.
But if you have a easy access to FreeBSD, you can check /usr/include/sys/types.h file and try to fix by adding ifdef

from zip.

randomMesh avatar randomMesh commented on May 19, 2024

Hi,

thanks for the quick answer. I made it compile.

I had a look at /usr/include/sys/types.h which looks like this:

#ifndef _SSIZE_T_DECLARED
typedef	__ssize_t	ssize_t;
#define	_SSIZE_T_DECLARED
#endif

So i added this to zip.h:

diff --git a/contrib/zip/src/zip.h b/contrib/zip/src/zip.h
index a48d64d6..d85306c8 100644
--- a/contrib/zip/src/zip.h
+++ b/contrib/zip/src/zip.h
@@ -21,7 +21,7 @@ extern "C" {
 
 #if !defined(_SSIZE_T_DEFINED) && !defined(_SSIZE_T_DEFINED_) &&               \
     !defined(__DEFINED_ssize_t) && !defined(__ssize_t_defined) &&              \
-    !defined(_SSIZE_T) && !defined(_SSIZE_T_)
+    !defined(_SSIZE_T) && !defined(_SSIZE_T_) && !defined(_SSIZE_T_DECLARED)
 
 // 64-bit Windows is the only mainstream platform
 // where sizeof(long) != sizeof(void*)
@@ -37,6 +37,7 @@ typedef long ssize_t; /* byte count or error */
 #define __ssize_t_defined
 #define _SSIZE_T
 #define _SSIZE_T_
+#define _SSIZE_T_DECLARED
 
 #endif
 

Thanks for the help!

from zip.

zeehead avatar zeehead commented on May 19, 2024

Hi @kuba--

so, I'm working on some code using Arduino IDE (2.0.0-rc6) and Blynk library, installed the latest esp32 board package (v 2.0.2).

And my code does compile, but still shows a red underline under the left bracket on

#include <BlynkSimpleEsp32_BT.h>

and it says this:

In included file: typedef redefinition with different types ('int' vs '_ssize_t' (aka 'long long'))clang(redefinition_different_typedef)
arch.h(202, 13): Error occurred here
types.h(184, 18): Previous definition is here

The path for types.h:

C:\Users\User\AppData\Local\Arduino15\packages\esp32\tools\xtensa-esp32-elf-gcc\gcc8_4_0-esp-2021r2\xtensa-esp32-elf\sys-include\sys\types.h

and this is the definition:

#ifndef _SSIZE_T_DECLARED
typedef _ssize_t ssize_t;
#define	_SSIZE_T_DECLARED
#endif

Path for arch.h:

C:\Users\User\AppData\Local\Arduino15\packages\esp32\hardware\esp32\2.0.2\tools\sdk\esp32\include\lwip\lwip\src\include\lwip\arch.h

and this is where the error ocurred:

#ifdef SSIZE_MAX
/* If SSIZE_MAX is defined, unistd.h should provide the type as well */
#ifndef LWIP_NO_UNISTD_H
#define LWIP_NO_UNISTD_H 0
#endif
#if !LWIP_NO_UNISTD_H
#include <unistd.h>
#endif
#else /* SSIZE_MAX */
typedef int ssize_t;
#define SSIZE_MAX INT_MAX
#endif /* SSIZE_MAX */

/* some maximum values needed in lwip code */
#define LWIP_UINT32_MAX 0xffffffff

Could you help me out here? I'm not sure what exactly I should change now in my case. Or should I just leave it, since it still compiles?

BTW, I hope I'm not posting in the wrong place here.

from zip.

kuba-- avatar kuba-- commented on May 19, 2024

@zeehead - size_t is tricky. On most platforms it's defined, but in a different way. But sometimes (very rarely) it's not defined at all. That's why we have the ifdef here: https://github.com/kuba--/zip/blob/master/src/zip.h#L37

Anyway, you can give me your platform name (how it's defined), so I can add it to the mentioned ifdef or you can (as a workaround):
#define _POSIX_C_SOURCE before you include zip.h.

from zip.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.