Thread: Testpad for itoa()

  1. #16
    C++まいる!Cをこわせ!
    Join Date
    Oct 2007
    Location
    Inside my computer
    Posts
    24,654
    Code:
                        Testing version : Elysia
                     ------------------------------
     Testing on AMD Athlon II X2 250 (3 GHz)
     OS = Windows 7 Ultimate 64 bit  --  Compiler = Microsoft Visual Studio 2010
    
     The value of num is: -1234567890
    
     The formatted value of num is: -1,234,567,890
    
     Elapsed time: 208 ms to perform 10,000,000 cycles
     -------------------------------------------------------
    
     handling 0 ---> 0
     handling 12 ---> 12
     handling 256 ---> 256
     handling 1000 --> 1,000
     handling 1000000 ---> 1,000,000
     handling 1000000000 ---> 1,000,000,000
     handling 2147483647 -> 2,147,483,647
     handling -2147483648 -> -2,147,483,648
    Press any key to continue . . .
    Code:
    // ----------------------------------------------------------------------------------------------
    // Prog_name: testpad.c 
    // A program for testing functions formatting integer numbers with 
    // thousand separators and sign. 
    //-----------------------------------------------------------------------------------------------
    // Created with Pelles C for Windows 6.00.4
    // Standard ISO C99
    //-----------------------------------------------------------------------------------------------
    // Date: 09 july 2010
    // Testpad by frktons
    //-----------------------------------------------------------------------------------------------
    
    #include <stdio.h>
    #include <time.h>
    #include <string.h>
    
    //-----------------------------------------------------------------------------------------------
    // Function prototype for itoa(). Takes in the number to 
    // format, and the pointer of the buffer to fill. Returns an int.
    //-----------------------------------------------------------------------------------------------
    
    void itoa(long num, char []);
    
    char digits_table[999999][8];
    
    //-----------------------------------------------------------------------------------------------
    
    int main(void)
    {
     
    	for (int i = 0; i < 999999; i++)
    	{
    		for (int j = 0; j < 8; j++)
    		{
    			digits_table[i][0] = ',';
    			digits_table[i][1] = '0' + char(i / 100000);
    			digits_table[i][2] = '0' + char(i / 10000 % 10);
    			digits_table[i][3] = '0' + char(i / 1000 % 10);
    			digits_table[i][4] = ',';
    			digits_table[i][5] = '0' + char(i / 100 % 10);
    			digits_table[i][6] = '0' + char(i / 10 % 10);
    			digits_table[i][7] = '0' + char(i % 10);
    		}
    	}
    	
    	long num = -1234567890;          // test number
        int cycles = 0;
    
    
    
        clock_t start = 0;              // initial time
        clock_t stop = 0;              // end time 
        const char *ver = "Elysia";         // Program version
        char buffer[50] = {'\0'};        // string array for the formatted number
                                                  // 10 digits max + 3 separators max + sign + NULL
     
        long times = 10000000;      // for testing performance set this number for repetitions
    
    //-----------------------------------------------------------------------------------------------
    // HW-SW platform 
    //-----------------------------------------------------------------------------------------------
        const char *OS = "Windows 7 Ultimate 64 bit";
    	const char *CPU = "AMD Athlon II X2 250 (3 GHz)";
        const char *compiler = "Microsoft Visual Studio 2010";
    //-----------------------------------------------------------------------------------------------
    
        printf("\n\t\t    Testing version : %s \n",ver);
        printf("\t\t ------------------------------\n");
    
        printf(" Testing on %s\n",CPU);
        printf(" OS = %s  --  Compiler = %s\n",OS,compiler);
        printf("\n The value of num is: %d\n",num);
    
        start = clock();
    
        for (cycles = 0; cycles < times; cycles++) {
    
            itoa(num,buffer);
    
        } // end for
    
        stop = clock();
        
        printf("\n The formatted value of num is: %s\n",buffer);
    
        itoa((long)(stop-start)/(CLOCKS_PER_SEC/1000),buffer);
        printf("\n Elapsed time: %s ms",buffer);
    
        itoa(times,buffer);
        printf(" to perform %s cycles\n",buffer);
    
    
    //------------------------------------------------------------------------------
    // Test some numbers
    //------------------------------------------------------------------------------
    
        printf(" -------------------------------------------------------\n");
    
        long test = -2147483647 - 1;
    	itoa(0,buffer);
        printf("\n handling 0 ---> %s",buffer);
        itoa(12,buffer);
        printf("\n handling 12 ---> %s",buffer);
        itoa(256,buffer);
        printf("\n handling 256 ---> %s",buffer);
        itoa(1000,buffer);
        printf("\n handling 1000 --> %s",buffer);
        itoa(1000000,buffer);
        printf("\n handling 1000000 ---> %s",buffer);
        itoa(1000000000,buffer);
        printf("\n handling 1000000000 ---> %s",buffer);
        itoa(2147483647,buffer);
        printf("\n handling 2147483647 -> %s",buffer);
        itoa(test,buffer);
        printf("\n handling -2147483648 -> %s\n",buffer);
    
        return 0;
    }
    
    //---------------------------------------------------------------
    // itoa() - Elysia's version
    //---------------------------------------------------------------
    __forceinline void itoa(long num, char buffer[])
    {
    	int remain = 0;                  // integer variable to store the remainder
    	bool neg = false;
    	const int sizeof_buffer = 30;
    	unsigned long newnum;
    
    	memset(buffer, 0, 50);
    
    	if (num == 0)
    	{
    		strcpy(buffer, "0");
    		return;
    	}
    	if (num < 0)
    	{
    		neg = true;
    		buffer[0] = '-';
    		newnum = -num; // transform number to positive if negative
    	}
    	else
    		newnum = num;
    
    	int x, copy_from_offset = 0;
    	for (x = sizeof_buffer - 1; newnum; x -= 8)
    	{
    		if (newnum < 100000)
    		{
    			copy_from_offset = 1;
    			if (newnum < 10) copy_from_offset = 6;
    			else if (newnum < 100) copy_from_offset = 5;
    			else if (newnum < 1000) copy_from_offset = 4;
    			else if (newnum < 10000) copy_from_offset = 2;
    		}
    		remain = newnum % 1000000;
    		newnum /= 1000000;
    		memcpy(&buffer[x - 8], digits_table[remain], 8);
    	} 
    
    	int copy_to = 0;
    	if (neg) copy_to++;
    	memmove(&buffer[copy_to], &buffer[x + 1] + copy_from_offset, sizeof_buffer - x - 1 - copy_from_offset);
    	buffer[sizeof_buffer - x - 1] = '\0';
    }
    There you go. Quick and dirt. x64 version (beats x86 version by ~2x).
    Last edited by Elysia; 07-09-2010 at 12:20 PM.
    Quote Originally Posted by Adak View Post
    io.h certainly IS included in some modern compilers. It is no longer part of the standard for C, but it is nevertheless, included in the very latest Pelles C versions.
    Quote Originally Posted by Salem View Post
    You mean it's included as a crutch to help ancient programmers limp along without them having to relearn too much.

    Outside of your DOS world, your header file is meaningless.

  2. #17
    Registered User
    Join Date
    Jun 2010
    Posts
    182
    Quote Originally Posted by Elysia View Post
    Code:
                        Testing version : Elysia
                     ------------------------------
     Testing on AMD Athlon II X2 250 (3 GHz)
     OS = Windows 7 Ultimate 64 bit  --  Compiler = Microsoft Visual Studio 2010
    
     The value of num is: -1234567890
    
     The formatted value of num is: -1,234,567,890
    
     Elapsed time: 208 ms to perform 10,000,000 cycles
     -------------------------------------------------------
    
     handling 0 ---> 0
     handling 12 ---> 12
     handling 256 ---> 256
     handling 1000 --> 1,000
     handling 1000000 ---> 1,000,000
     handling 1000000000 ---> 1,000,000,000
     handling 2147483647 -> 2,147,483,647
     handling -2147483648 -> -2,147,483,648
    Press any key to continue . . .
    Code:
    // ----------------------------------------------------------------------------------------------
    // Prog_name: testpad.c 
    // A program for testing functions formatting integer numbers with 
    // thousand separators and sign. 
    //-----------------------------------------------------------------------------------------------
    // Created with Pelles C for Windows 6.00.4
    // Standard ISO C99
    //-----------------------------------------------------------------------------------------------
    // Date: 09 july 2010
    // Testpad by frktons
    //-----------------------------------------------------------------------------------------------
    
    #include <stdio.h>
    #include <time.h>
    #include <string.h>
    
    //-----------------------------------------------------------------------------------------------
    // Function prototype for itoa(). Takes in the number to 
    // format, and the pointer of the buffer to fill. Returns an int.
    //-----------------------------------------------------------------------------------------------
    
    void itoa(long num, char []);
    
    char digits_table[999999][8];
    
    //-----------------------------------------------------------------------------------------------
    
    int main(void)
    {
     
    	for (int i = 0; i < 999999; i++)
    	{
    		for (int j = 0; j < 8; j++)
    		{
    			digits_table[i][0] = ',';
    			digits_table[i][1] = '0' + char(i / 100000);
    			digits_table[i][2] = '0' + char(i / 10000 % 10);
    			digits_table[i][3] = '0' + char(i / 1000 % 10);
    			digits_table[i][4] = ',';
    			digits_table[i][5] = '0' + char(i / 100 % 10);
    			digits_table[i][6] = '0' + char(i / 10 % 10);
    			digits_table[i][7] = '0' + char(i % 10);
    		}
    	}
    	
    	long num = -1234567890;          // test number
        int cycles = 0;
    
    
    
        clock_t start = 0;              // initial time
        clock_t stop = 0;              // end time 
        const char *ver = "Elysia";         // Program version
        char buffer[50] = {'\0'};        // string array for the formatted number
                                                  // 10 digits max + 3 separators max + sign + NULL
     
        long times = 10000000;      // for testing performance set this number for repetitions
    
    //-----------------------------------------------------------------------------------------------
    // HW-SW platform 
    //-----------------------------------------------------------------------------------------------
        const char *OS = "Windows 7 Ultimate 64 bit";
    	const char *CPU = "AMD Athlon II X2 250 (3 GHz)";
        const char *compiler = "Microsoft Visual Studio 2010";
    //-----------------------------------------------------------------------------------------------
    
        printf("\n\t\t    Testing version : %s \n",ver);
        printf("\t\t ------------------------------\n");
    
        printf(" Testing on %s\n",CPU);
        printf(" OS = %s  --  Compiler = %s\n",OS,compiler);
        printf("\n The value of num is: %d\n",num);
    
        start = clock();
    
        for (cycles = 0; cycles < times; cycles++) {
    
            itoa(num,buffer);
    
        } // end for
    
        stop = clock();
        
        printf("\n The formatted value of num is: %s\n",buffer);
    
        itoa((long)(stop-start)/(CLOCKS_PER_SEC/1000),buffer);
        printf("\n Elapsed time: %s ms",buffer);
    
        itoa(times,buffer);
        printf(" to perform %s cycles\n",buffer);
    
    
    //------------------------------------------------------------------------------
    // Test some numbers
    //------------------------------------------------------------------------------
    
        printf(" -------------------------------------------------------\n");
    
        long test = -2147483647 - 1;
    	itoa(0,buffer);
        printf("\n handling 0 ---> %s",buffer);
        itoa(12,buffer);
        printf("\n handling 12 ---> %s",buffer);
        itoa(256,buffer);
        printf("\n handling 256 ---> %s",buffer);
        itoa(1000,buffer);
        printf("\n handling 1000 --> %s",buffer);
        itoa(1000000,buffer);
        printf("\n handling 1000000 ---> %s",buffer);
        itoa(1000000000,buffer);
        printf("\n handling 1000000000 ---> %s",buffer);
        itoa(2147483647,buffer);
        printf("\n handling 2147483647 -> %s",buffer);
        itoa(test,buffer);
        printf("\n handling -2147483648 -> %s\n",buffer);
    
        return 0;
    }
    
    //---------------------------------------------------------------
    // itoa() - Elysia's version
    //---------------------------------------------------------------
    __forceinline void itoa(long num, char buffer[])
    {
    	int remain = 0;                  // integer variable to store the remainder
    	bool neg = false;
    	const int sizeof_buffer = 30;
    	unsigned long newnum;
    
    	memset(buffer, 0, 50);
    
    	if (num == 0)
    	{
    		strcpy(buffer, "0");
    		return;
    	}
    	if (num < 0)
    	{
    		neg = true;
    		buffer[0] = '-';
    		newnum = -num; // transform number to positive if negative
    	}
    	else
    		newnum = num;
    
    	int x, copy_from_offset = 0;
    	for (x = sizeof_buffer - 1; newnum; x -= 8)
    	{
    		if (newnum < 100000)
    		{
    			copy_from_offset = 1;
    			if (newnum < 10) copy_from_offset = 6;
    			else if (newnum < 100) copy_from_offset = 5;
    			else if (newnum < 1000) copy_from_offset = 4;
    			else if (newnum < 10000) copy_from_offset = 2;
    		}
    		remain = newnum % 1000000;
    		newnum /= 1000000;
    		memcpy(&buffer[x - 8], digits_table[remain], 8);
    	} 
    
    	int copy_to = 0;
    	if (neg) copy_to++;
    	memmove(&buffer[copy_to], &buffer[x + 1] + copy_from_offset, sizeof_buffer - x - 1 - copy_from_offset);
    	buffer[sizeof_buffer - x - 1] = '\0';
    }
    There you go. Quick and dirt. x64 version (beats x86 version by ~2x).
    Very good Elysia, thanks for your collaboration.
    Unfortunately it seems not strictly C99 standard:
    Code:
    Building testpad.obj.
    testpad.c(36): error #2039: Illegal expression.
    testpad.c(36): error #2068: Expected a function but found 'int'.
    testpad.c(36): error #2168: Operands of '+' have incompatible types 'int' and 'void'.
    testpad.c(37): error #2039: Illegal expression.
    testpad.c(37): error #2068: Expected a function but found 'int'.
    testpad.c(37): error #2168: Operands of '+' have incompatible types 'int' and 'void'.
    testpad.c(38): error #2039: Illegal expression.
    testpad.c(38): error #2068: Expected a function but found 'int'.
    testpad.c(38): error #2168: Operands of '+' have incompatible types 'int' and 'void'.
    testpad.c(40): error #2039: Illegal expression.
    testpad.c(40): error #2068: Expected a function but found 'int'.
    testpad.c(40): error #2168: Operands of '+' have incompatible types 'int' and 'void'.
    testpad.c(41): error #2039: Illegal expression.
    testpad.c(41): error #2068: Expected a function but found 'int'.
    testpad.c(41): error #2168: Operands of '+' have incompatible types 'int' and 'void'.
    testpad.c(42): error #2039: Illegal expression.
    testpad.c(42): error #2068: Expected a function but found 'int'.
    testpad.c(42): error #2168: Operands of '+' have incompatible types 'int' and 'void'.
    testpad.c(126): error #2048: Undeclared identifier 'bool'.
    testpad.c(126): error #2001: Syntax error: expected ';' but found 'neg'.
    testpad.c(126): error #2048: Undeclared identifier 'neg'.
    testpad.c(126): error #2048: Undeclared identifier 'false'.
    testpad.c(139): error #2048: Undeclared identifier 'true'.
    testpad.c(126): warning #2114: Local 'bool' is not referenced.
    *** Error code: 1 ***
    Done.
    My compiler complains about:

    Code:
    			digits_table[i][0] = ',';
    			digits_table[i][1] = '0' + char(i / 100000);
    			digits_table[i][2] = '0' + char(i / 10000 % 10);
    			digits_table[i][3] = '0' + char(i / 1000 % 10);
    			digits_table[i][4] = ',';
    			digits_table[i][5] = '0' + char(i / 100 % 10);
    			digits_table[i][6] = '0' + char(i / 10 % 10);
    			digits_table[i][7] = '0' + char(i % 10);
    Any possible standard coding?

  3. #18
    C++ Witch laserlight's Avatar
    Join Date
    Oct 2003
    Location
    Singapore
    Posts
    28,413
    Those look like function-style casts from C++. I expect that they should be:
    Code:
    digits_table[i][1] = '0' + (char)(i / 100000);
    etc. However, the explicit cast is probably unnecessary anyway, since the result would be promoted back to int for the addition.
    Quote Originally Posted by Bjarne Stroustrup (2000-10-14)
    I get maybe two dozen requests for help with some sort of programming or design problem every day. Most have more sense than to send me hundreds of lines of code. If they do, I ask them to find the smallest example that exhibits the problem and send me that. Mostly, they then find the error themselves. "Finding the smallest program that demonstrates the error" is a powerful debugging tool.
    Look up a C++ Reference and learn How To Ask Questions The Smart Way

  4. #19
    C++まいる!Cをこわせ!
    Join Date
    Oct 2007
    Location
    Inside my computer
    Posts
    24,654
    Right. You complained about that before, but you never said if my solution fixed it... I don't think GCC likes that syntax for some reason.
    Change it to:
    Code:
    			digits_table[i][0] = ',';
    			digits_table[i][1] = '0' + (char)(i / 100000);
    			digits_table[i][2] = '0' + (char)(i / 10000 % 10);
    			digits_table[i][3] = '0' + (char)(i / 1000 % 10);
    			digits_table[i][4] = ',';
    			digits_table[i][5] = '0' + (char)(i / 100 % 10);
    			digits_table[i][6] = '0' + (char)(i / 10 % 10);
    			digits_table[i][7] = '0' + (char)(i % 10);
    And try again.

    Also, for bool, try:
    Code:
    #ifndef _MSC_VER
    #include <stdbool.h>
    #endif
    MSVC doesn't support C99.
    The first line should be cast to char since otherwise you'll get a warning of int to char: possible loss of data. You could add % 10 to it, or you could cast it. Your choice. The rest doesn't seem to need the cast, though.

    And did you have to quote the entire post?
    Last edited by Elysia; 07-09-2010 at 01:31 PM.
    Quote Originally Posted by Adak View Post
    io.h certainly IS included in some modern compilers. It is no longer part of the standard for C, but it is nevertheless, included in the very latest Pelles C versions.
    Quote Originally Posted by Salem View Post
    You mean it's included as a crutch to help ancient programmers limp along without them having to relearn too much.

    Outside of your DOS world, your header file is meaningless.

  5. #20
    Registered User
    Join Date
    Jun 2010
    Posts
    182
    OK Elysia, changing the code with (char) typecasting worked.
    The results on my pc:
    Code:
                        Testing version : Elysia
                     ------------------------------
     Testing on Intel Core Duo 6600 2.4 Ghz
     OS = Windows 7 Ultimate 64 bit  --  Compiler = Pelles C 6.00.4
    
     The value of num is: -1234567890
    
     The formatted value of num is: -1,234,567,890
    
     Elapsed time: 936 ms to perform 10,000,000 cycles
     -------------------------------------------------------
    
     handling 0 ---> 0
     handling 12 ---> 12
     handling 256 ---> 256
     handling 1000 --> 1,000
     handling 1000000 ---> 1,000,000
     handling 1000000000 ---> 1,000,000,000
     handling 2147483647 -> 2,147,483,647
     handling -2147483648 -> -2,147,483,648
    Press any key to continue...
    This is going to be one of the selected working solutions.

    If you post the EXE compiled with 64 bit features, it'll probably
    test faster on my pc as well.

    Thanks
    Last edited by frktons; 07-09-2010 at 02:04 PM.

  6. #21
    C++まいる!Cをこわせ!
    Join Date
    Oct 2007
    Location
    Inside my computer
    Posts
    24,654
    Compile an x64 build, as well, should you be able. The code was made to lend itself well to that since it performs a 64-bit move per loop.
    Quote Originally Posted by Adak View Post
    io.h certainly IS included in some modern compilers. It is no longer part of the standard for C, but it is nevertheless, included in the very latest Pelles C versions.
    Quote Originally Posted by Salem View Post
    You mean it's included as a crutch to help ancient programmers limp along without them having to relearn too much.

    Outside of your DOS world, your header file is meaningless.

  7. #22
    Registered User
    Join Date
    Jun 2010
    Posts
    182
    Quote Originally Posted by Elysia View Post
    Compile an x64 build, as well, should you be able. The code was made to lend itself well to that since it performs a 64-bit move per loop.
    I don't think I can do it with Pelles' C. If I use the command line CL.EXE
    from MSVC 2010, that I have somewhere on my pc, what command line should I use?

  8. #23
    C++まいる!Cをこわせ!
    Join Date
    Oct 2007
    Location
    Inside my computer
    Posts
    24,654
    No idea. Not using command lines (what do you think IDEs are for?).
    But this is all the more reason to drop your compiler. We've already shown that GCC and MSVC beats it at optimizing.
    Quote Originally Posted by Adak View Post
    io.h certainly IS included in some modern compilers. It is no longer part of the standard for C, but it is nevertheless, included in the very latest Pelles C versions.
    Quote Originally Posted by Salem View Post
    You mean it's included as a crutch to help ancient programmers limp along without them having to relearn too much.

    Outside of your DOS world, your header file is meaningless.

  9. #24
    C++ Witch laserlight's Avatar
    Join Date
    Oct 2003
    Location
    Singapore
    Posts
    28,413
    Quote Originally Posted by frktons
    I don't think I can do it with Pelles' C.
    The Pelles C homepage states that it supports 64-bit compilation, though obtaining the documentation on how to do that is another matter as there are no obvious links on the website or wiki.
    Quote Originally Posted by Bjarne Stroustrup (2000-10-14)
    I get maybe two dozen requests for help with some sort of programming or design problem every day. Most have more sense than to send me hundreds of lines of code. If they do, I ask them to find the smallest example that exhibits the problem and send me that. Mostly, they then find the error themselves. "Finding the smallest program that demonstrates the error" is a powerful debugging tool.
    Look up a C++ Reference and learn How To Ask Questions The Smart Way

  10. #25
    C++まいる!Cをこわせ!
    Join Date
    Oct 2007
    Location
    Inside my computer
    Posts
    24,654
    I suppose you should also rerun iMalc's code to measure it in ms instead of clock ticks.
    (For a fair comparison; otherwise we don't know by how many orders of magnitude slower or faster other codes are.)
    Quote Originally Posted by Adak View Post
    io.h certainly IS included in some modern compilers. It is no longer part of the standard for C, but it is nevertheless, included in the very latest Pelles C versions.
    Quote Originally Posted by Salem View Post
    You mean it's included as a crutch to help ancient programmers limp along without them having to relearn too much.

    Outside of your DOS world, your header file is meaningless.

  11. #26
    Registered User
    Join Date
    Jun 2010
    Posts
    182
    Quote Originally Posted by Elysia View Post
    I suppose you should also rerun iMalc's code
    to measure it in ms instead of clock ticks.
    (For a fair comparison; otherwise we don't know by how many orders
    of magnitude slower or faster other codes are.)
    My pc is 32 bit, so Pelles'C 64 bit refuses to compile in x64 mode.

    Code:
        itoa((long)(stop-start)/(CLOCKS_PER_SEC/1000),buffer);
        printf("\n Elapsed time: %s ms",buffer);
    I didn't see you changed the timing system, ok, I'll change it on the
    testpad and retest iMalc version.
    Results following:

    Code:
                        Testing version : iMalc
                     ------------------------------
     Testing on Intel Core Duo 6600 2.4 Ghz
     OS = Windows 7 Ultimate 64 bit  --  Compiler = Pelles C 6.00.4
    
     The value of num is: -1234567890
    
     The formatted value of num is: -1,234,567,890
    
     Elapsed time: 297 ms to perform 10,000,000 cycles
     -------------------------------------------------------
    
     handling 0 ---> 0
     handling 12 ---> 12
     handling 256 ---> 256
     handling 1000 --> 1,000
     handling 1000000 ---> 1,000,000
     handling 1000000000 ---> 1,000,000,000
     handling 2147483647 -> 2,147,483,647
     handling -2147483648 -> -2,147,483,648
    See you later :-)

    Edit: Well, doesn't seem to change a lot from previous system.
    Last edited by frktons; 07-09-2010 at 02:33 PM.

  12. #27
    C++まいる!Cをこわせ!
    Join Date
    Oct 2007
    Location
    Inside my computer
    Posts
    24,654
    Wait. What?

    Testing on Intel Core Duo 6600 2.4 Ghz
    OS = Windows 7 Ultimate 64 bit -- Compiler = Pelles C 6.00.4
    My pc is 32 bit, so Pelles'C 64 bit refuses to compile in x64 mode.

    Something here isn't right. You use a 64-bit system. You have a Core Duo (not Core 2 Duo), which AFAIK, doesn't support x64 AND you say your PC is x86...
    Quote Originally Posted by Adak View Post
    io.h certainly IS included in some modern compilers. It is no longer part of the standard for C, but it is nevertheless, included in the very latest Pelles C versions.
    Quote Originally Posted by Salem View Post
    You mean it's included as a crutch to help ancient programmers limp along without them having to relearn too much.

    Outside of your DOS world, your header file is meaningless.

  13. #28
    Registered User
    Join Date
    Jun 2010
    Posts
    182
    Quote Originally Posted by Elysia View Post
    Wait. What?

    Testing on Intel Core Duo 6600 2.4 Ghz
    OS = Windows 7 Ultimate 64 bit -- Compiler = Pelles C 6.00.4
    My pc is 32 bit, so Pelles'C 64 bit refuses to compile in x64 mode.

    Something here isn't right. You use a 64-bit system. You have a Core Duo (not Core 2 Duo), which AFAIK, doesn't support x64 AND you say your PC is x86...
    It is a Core 2 Duo E6600 - IA32 architecture, but supports some x64 software features.
    The OS is 64 bit and works fine.

    By the way, if I try to compile in x64 mode Pelles C gives these errors:
    Code:
    POLINK: error: Unresolved external symbol '__imp_GetSystemTimeAsFileTime'.
    POLINK: error: Unresolved external symbol '__imp_HeapCreate'.
    POLINK: error: Unresolved external symbol '__imp_HeapDestroy'.
    POLINK: error: Unresolved external symbol '__imp_HeapAlloc'.
    POLINK: error: Unresolved external symbol '__imp_HeapReAlloc'.
    POLINK: error: Unresolved external symbol '__imp_HeapFree'.
    POLINK: error: Unresolved external symbol '__imp_HeapSize'.
    POLINK: error: Unresolved external symbol '__imp_HeapValidate'.
    POLINK: error: Unresolved external symbol '__imp_ExitProcess'.
    POLINK: error: Unresolved external symbol '__imp_GetStartupInfoA'.
    POLINK: error: Unresolved external symbol '__imp_GetFileType'.
    POLINK: error: Unresolved external symbol '__imp_GetStdHandle'.
    POLINK: error: Unresolved external symbol '__imp_GetCurrentProcess'.
    POLINK: error: Unresolved external symbol '__imp_DuplicateHandle'.
    POLINK: error: Unresolved external symbol '__imp_SetHandleCount'.
    POLINK: error: Unresolved external symbol '__imp_GetCommandLineA'.
    POLINK: error: Unresolved external symbol '__imp_GetModuleFileNameA'.
    POLINK: error: Unresolved external symbol '__imp_GetEnvironmentStrings'.
    POLINK: error: Unresolved external symbol '__imp_FreeEnvironmentStringsA'.
    POLINK: error: Unresolved external symbol '__imp_UnhandledExceptionFilter'.
    POLINK: error: Unresolved external symbol '__imp_RtlUnwindEx'.
    POLINK: error: Unresolved external symbol '__imp_ReadFile'.
    POLINK: error: Unresolved external symbol '__imp_GetLastError'.
    POLINK: error: Unresolved external symbol '__imp_GetConsoleMode'.
    POLINK: error: Unresolved external symbol '__imp_GetConsoleCP'.
    POLINK: error: Unresolved external symbol '__imp_SetConsoleCtrlHandler'.
    POLINK: error: Unresolved external symbol '__imp_GetConsoleOutputCP'.
    POLINK: error: Unresolved external symbol '__imp_WriteFile'.
    POLINK: error: Unresolved external symbol '__imp_MultiByteToWideChar'.
    POLINK: error: Unresolved external symbol '__imp_VirtualAlloc'.
    POLINK: error: Unresolved external symbol '__imp_VirtualQuery'.
    POLINK: error: Unresolved external symbol '__imp_SetStdHandle'.
    POLINK: error: Unresolved external symbol '__imp_SetFilePointer'.
    POLINK: error: Unresolved external symbol '__imp_WideCharToMultiByte'.
    POLINK: error: Unresolved external symbol '__imp_CloseHandle'.
    POLINK: error: Unresolved external symbol '__imp_DeleteFileA'.
    maybe I miss an #include somewhere.

    OK, solved. In X64 mode I have:
    Code:
                        Testing version : iMalc
                     ------------------------------
     Testing on Intel Core 2 Duo E6600 2.4 Ghz IA32
     OS = Windows 7 Ultimate 64 bit  --  Compiler = Pelles C 6.00.4
    
     The value of num is: -1234567890
    
     The formatted value of num is: -1,234,567,890
    
     Elapsed time: 265 ms to perform 10,000,000 cycles
     -------------------------------------------------------
    
     handling 0 ---> 0
     handling 12 ---> 12
     handling 256 ---> 256
     handling 1000 --> 1,000
     handling 1000000 ---> 1,000,000
     handling 1000000000 ---> 1,000,000,000
     handling 2147483647 -> 2,147,483,647
     handling -2147483648 -> -2,147,483,648
    and

    Code:
                        Testing version : Elysia
                     ------------------------------
     Testing on Intel Core 2 Duo E6600 2.4 Ghz IA32
     OS = Windows 7 Ultimate 64 bit  --  Compiler = Pelles C 6.00.4
    
     The value of num is: -1234567890
    
     The formatted value of num is: -1,234,567,890
    
     Elapsed time: 905 ms to perform 10,000,000 cycles
     -------------------------------------------------------
    
     handling 0 ---> 0
     handling 12 ---> 12
     handling 256 ---> 256
     handling 1000 --> 1,000
     handling 1000000 ---> 1,000,000
     handling 1000000000 ---> 1,000,000,000
     handling 2147483647 -> 2,147,483,647
     handling -2147483648 -> -2,147,483,648
    Press any key to continue...
    Last edited by frktons; 07-09-2010 at 03:25 PM.

  14. #29
    C++まいる!Cをこわせ!
    Join Date
    Oct 2007
    Location
    Inside my computer
    Posts
    24,654
    This is not missing includes! This is missing libraries.
    Quote Originally Posted by Adak View Post
    io.h certainly IS included in some modern compilers. It is no longer part of the standard for C, but it is nevertheless, included in the very latest Pelles C versions.
    Quote Originally Posted by Salem View Post
    You mean it's included as a crutch to help ancient programmers limp along without them having to relearn too much.

    Outside of your DOS world, your header file is meaningless.

  15. #30
    Registered User
    Join Date
    Jun 2010
    Posts
    182
    Quote Originally Posted by Elysia View Post
    This is not missing includes! This is missing libraries.
    Sorry Elysia, I still don't know very well Pelles C.
    I had to create a Win 64 console project and everything went
    all right, see my previous post.

Popular pages Recent additions subscribe to a feed