Hi ! Thanks for the report. Thomas already notified me that on our GCC linux 
bots, the %Iu specifier gave a warning (but not an error). I’ll fix that in a 
subsequent commit (together with other improvements I need), but for now you 
can instead use %lu (lowercase ell, instead of uppercase i) and cast the buflen 
variable to unsigned long in the printf call (as a “quick” fix).

 

Cheers,

Hermès.

 

De : Ros-dev [mailto:[email protected]] De la part de Steven Edwards
Envoyé : lundi 22 juin 2015 16:38
À : ReactOS Development List
Cc : [email protected]
Objet : Re: [ros-dev] [ros-diffs] [hbelusca] 68139: [TOOLS] Improve bin2c by 
saving in a #define the size of the generated array, and specify this size in 
the declaration of the array so that doing sizeof(...) becomes possible. Use...

 

This causes failures in cross-compiling on OS X

[15/6897] Building C object 
hal/halx86/CMakeFiles/lib_hal_legacy.dir/pci_classes.c.obj

FAILED: /usr/local/RosBE/i386/bin/i686-w64-mingw32-gcc  -DDBG=1 -DKDBG=1 
-DUSE_COMPILER_EXCEPTIONS -DWINVER=0x502 -D_M_IX86 -D_NTHALDLL_ -D_NTHAL_ 
-D_SEH_ENABLE_TRACE -D_SETUPAPI_VER=0x502 -D_USE_32BIT_TIME_T -D_USE_PSEH3=1 
-D_WIN32_IE=0x600 -D_WIN32_WINDOWS=0x502 -D_WIN32_WINNT=0x502 -D_X86_ 
-D__REACTOS__ -D__i386__ -D_inline=__inline -Di386 
-Wa,--compress-debug-sections -pipe -fms-extensions -fno-strict-aliasing 
-nostdinc -mstackrealign -Wold-style-declaration -Wdeclaration-after-statement 
-fdebug-prefix-map="/Users/steven.edwards/source/reactos/reactos"=ReactOS 
-gdwarf-2 -gstrict-dwarf -femit-struct-debug-detailed=none 
-feliminate-unused-debug-symbols -march=pentium -mtune=i686 -Werror -Wall 
-Wpointer-arith -Wno-char-subscripts -Wno-multichar -Wno-unused-value 
-Wno-maybe-uninitialized -O1 -fno-optimize-sibling-calls 
-fno-omit-frame-pointer -mpreferred-stack-boundary=3 -fno-set-stack-executable 
-g -Ihal/halx86 -I../../hal/halx86 -I../../include -I../../include/psdk 
-I../../include/dxsdk -Iinclude -Iinclude/psdk -Iinclude/dxsdk 
-Iinclude/reactos -I../../include/crt -I../../include/ddk -I../../include/ndk 
-I../../include/reactos -I../../include/reactos/libs -I../../hal/halx86/include 
-I../../ntoskrnl/include -MMD -MT 
hal/halx86/CMakeFiles/lib_hal_legacy.dir/pci_classes.c.obj -MF 
hal/halx86/CMakeFiles/lib_hal_legacy.dir/pci_classes.c.obj.d -o 
hal/halx86/CMakeFiles/lib_hal_legacy.dir/pci_classes.c.obj -c 
hal/halx86/pci_classes.c

In file included from hal/halx86/pci_classes.c:4:0:

/Users/steven.edwards/source/reactos/reactos/output-MinGW-i386/reactos/hal/halx86/pci_classes.h:4:33:
 error: 'Iu' undeclared here (not in a function)

[15/6897] Building C object 
hal/halx86/CMakeFiles/lib_hal_legacy.dir/legacy/bussupp.c.obj

FAILED: /usr/local/RosBE/i386/bin/i686-w64-mingw32-gcc  -DDBG=1 -DKDBG=1 
-DUSE_COMPILER_EXCEPTIONS -DWINVER=0x502 -D_M_IX86 -D_NTHALDLL_ -D_NTHAL_ 
-D_SEH_ENABLE_TRACE -D_SETUPAPI_VER=0x502 -D_USE_32BIT_TIME_T -D_USE_PSEH3=1 
-D_WIN32_IE=0x600 -D_WIN32_WINDOWS=0x502 -D_WIN32_WINNT=0x502 -D_X86_ 
-D__REACTOS__ -D__i386__ -D_inline=__inline -Di386 
-Wa,--compress-debug-sections -pipe -fms-extensions -fno-strict-aliasing 
-nostdinc -mstackrealign -Wold-style-declaration -Wdeclaration-after-statement 
-fdebug-prefix-map="/Users/steven.edwards/source/reactos/reactos"=ReactOS 
-gdwarf-2 -gstrict-dwarf -femit-struct-debug-detailed=none 
-feliminate-unused-debug-symbols -march=pentium -mtune=i686 -Werror -Wall 
-Wpointer-arith -Wno-char-subscripts -Wno-multichar -Wno-unused-value 
-Wno-maybe-uninitialized -O1 -fno-optimize-sibling-calls 
-fno-omit-frame-pointer -mpreferred-stack-boundary=3 -fno-set-stack-executable 
-g -Ihal/halx86 -I../../hal/halx86 -I../../include -I../../include/psdk 
-I../../include/dxsdk -Iinclude -Iinclude/psdk -Iinclude/dxsdk 
-Iinclude/reactos -I../../include/crt -I../../include/ddk -I../../include/ndk 
-I../../include/reactos -I../../include/reactos/libs -I../../hal/halx86/include 
-I../../ntoskrnl/include -MMD -MT 
hal/halx86/CMakeFiles/lib_hal_legacy.dir/legacy/bussupp.c.obj -MF 
hal/halx86/CMakeFiles/lib_hal_legacy.dir/legacy/bussupp.c.obj.d -o 
hal/halx86/CMakeFiles/lib_hal_legacy.dir/legacy/bussupp.c.obj -c 
../../hal/halx86/legacy/bussupp.c

In file included from ../../hal/halx86/legacy/bussupp.c:697:0:

hal/halx86/pci_classes.h:4:33: error: 'Iu' undeclared here (not in a function)

../../hal/halx86/legacy/bussupp.c: In function 'HalpDebugPciDumpBus':

../../hal/halx86/legacy/bussupp.c:739:32: error: 'VendorTable' undeclared 
(first use in this function)

../../hal/halx86/legacy/bussupp.c:739:32: note: each undeclared identifier is 
reported only once for each function it appears in

[15/6897] Building C object 
lib/3rdparty/adns/CMakeFiles/adns.dir/src/event.c.obj

ninja: build stopped: subcommand failed.

 

On Sun, Jun 14, 2015 at 11:13 AM, <[email protected]> wrote:

Author: hbelusca
Date: Sun Jun 14 18:13:50 2015
New Revision: 68139

URL: http://svn.reactos.org/svn/reactos?rev=68139 
<http://svn.reactos.org/svn/reactos?rev=68139&view=rev> &view=rev
Log:
[TOOLS]
Improve bin2c by saving in a #define the size of the generated array, and 
specify this size in the declaration of the array so that doing sizeof(...) 
becomes possible. Use "unsigned char" as the (portable) type of the contents of 
the array.

[HAL]
Add PCHAR casts where needed to take into account the previous modifications.

Modified:
    trunk/reactos/hal/halx86/legacy/bussupp.c
    trunk/reactos/tools/bin2c.c

Modified: trunk/reactos/hal/halx86/legacy/bussupp.c
URL: 
http://svn.reactos.org/svn/reactos/trunk/reactos/hal/halx86/legacy/bussupp.c?rev=68139
 
<http://svn.reactos.org/svn/reactos/trunk/reactos/hal/halx86/legacy/bussupp.c?rev=68139&r1=68138&r2=68139&view=diff>
 &r1=68138&r2=68139&view=diff
==============================================================================
--- trunk/reactos/hal/halx86/legacy/bussupp.c   [iso-8859-1] (original)
+++ trunk/reactos/hal/halx86/legacy/bussupp.c   [iso-8859-1] Sun Jun 14 
18:13:50 2015
@@ -715,7 +715,7 @@

     /* Isolate the class name */
     sprintf(LookupString, "C %02x  ", PciData->BaseClass);
-    ClassName = strstr(ClassTable, LookupString);
+    ClassName = strstr((PCHAR)ClassTable, LookupString);
     if (ClassName)
     {
         /* Isolate the subclass name */
@@ -736,7 +736,7 @@

     /* Isolate the vendor name */
     sprintf(LookupString, "\r\n%04x  ", PciData->VendorID);
-    VendorName = strstr(VendorTable, LookupString);
+    VendorName = strstr((PCHAR)VendorTable, LookupString);
     if (VendorName)
     {
         /* Copy the vendor name into our buffer */

Modified: trunk/reactos/tools/bin2c.c
URL: http://svn.reactos.org/svn/reactos/trunk/reactos/tools/bin2c.c?rev=68139 
<http://svn.reactos.org/svn/reactos/trunk/reactos/tools/bin2c.c?rev=68139&r1=68138&r2=68139&view=diff>
 &r1=68138&r2=68139&view=diff
==============================================================================
--- trunk/reactos/tools/bin2c.c [iso-8859-1] (original)
+++ trunk/reactos/tools/bin2c.c [iso-8859-1] Sun Jun 14 18:13:50 2015
@@ -13,8 +13,8 @@
     FILE* inFile;
     FILE* outCFile;
     FILE* outHFile;
+    size_t bufLen;
     unsigned char ch;
-    unsigned char cnt;

     /* Validate the arguments */
     if (argc < 5)
@@ -46,14 +46,6 @@
         return -1;
     }

-    /* Generate the header file and close it */
-    fprintf(outHFile, "/* This file is autogenerated, do not edit. */\n\n");
-    fprintf(outHFile, "#ifndef CHAR\n"
-                      "#define CHAR char\n"
-                      "#endif\n\n");
-    fprintf(outHFile, "extern CHAR %s[];\n", argv[4]);
-    fclose(outHFile);
-
     /* Generate the source file and close it */
     fprintf(outCFile, "/* This file is autogenerated, do not edit. */\n\n");
     if (argc >= 7)
@@ -69,25 +61,29 @@
         /* Add the array attribute */
         fprintf(outCFile, "%s ", argv[5]);
     }
-    fprintf(outCFile, "CHAR %s[] =\n{", argv[4]);
+    fprintf(outCFile, "unsigned char %s[] =\n{", argv[4]);

-    cnt = 0;
-    ch  = fgetc(inFile);
+    bufLen = 0;
+    ch = fgetc(inFile);
     while (!feof(inFile))
     {
-        if ((cnt % 16) == 0)
-        {
+        if ((bufLen % 16) == 0)
             fprintf(outCFile, "\n   ");
-            cnt = 0;
-        }
+
         fprintf(outCFile, " 0x%02x,", (unsigned int)ch);
-        ++cnt;
+        ++bufLen;
         ch = fgetc(inFile);
     }
     /* Put a final NULL terminator */
-    fprintf(outCFile, "\n    0x00");
+    fprintf(outCFile, "\n    0x00"); ++bufLen;
     fprintf(outCFile, "\n};\n");
     fclose(outCFile);
+
+    /* Generate the header file and close it */
+    fprintf(outHFile, "/* This file is autogenerated, do not edit. */\n\n");
+    fprintf(outHFile, "#define %s_SIZE %Iu\n"          , argv[4], bufLen);
+    fprintf(outHFile, "extern unsigned char %s[%Iu];\n", argv[4], bufLen);
+    fclose(outHFile);

     /* Close the input file */
     fclose(inFile);







 

-- 

Steven Edwards

"There is one thing stronger than all the armies in the world, and that is an 
idea whose time has come." - Victor Hugo

_______________________________________________
Ros-dev mailing list
[email protected]
http://www.reactos.org/mailman/listinfo/ros-dev

Reply via email to