NO

Recent Posts

Pages: [1] 2 3 ... 10
1
Beginner questions / Re: Alignment
« Last post by Vortex on Today at 06:41:50 pm »
Hi Grincheux,

Testing this  code :

Code: [Select]
#include <stdio.h>

int main()
{
char szNullString[] = "\0" ;
char szString1[] = "1" ;
char szString2[] = "12" ;
char szString3[] = "123" ;
char szString4[] = "1234" ;

return 0;
}

The diassembly of the object module :
Code: [Select]
.386
option dotname
.model flat

public _main

_text   SEGMENT PARA PUBLIC 'CODE'

_main   PROC NEAR
        push    ebp
        mov     ebp, esp
        sub     esp, 16
        mov     byte ptr [ebp-2H], 0
        mov     byte ptr [ebp-1H], 0
        mov     byte ptr [ebp-4H], 49
        mov     byte ptr [ebp-3H], 0
        mov     byte ptr [ebp-7H], 49
        mov     byte ptr [ebp-6H], 50
        mov     byte ptr [ebp-5H], 0
        mov     byte ptr [ebp-0BH], 49
        mov     byte ptr [ebp-0AH], 50
        mov     byte ptr [ebp-9H], 51
        mov     byte ptr [ebp-8H], 0
        mov     byte ptr [ebp-10H], 49
        mov     byte ptr [ebp-0FH], 50
        mov     byte ptr [ebp-0EH], 51
        mov     byte ptr [ebp-0DH], 52
        mov     byte ptr [ebp-0CH], 0
        mov     eax, 0
        mov     esp, ebp
        pop     ebp
        ret
_main   ENDP

_text   ENDS
2
Beginner questions / Re: Alignment
« Last post by Pelle on Today at 05:05:09 pm »
No reason to give char a stricter alignment than byte (I'm not convinced many assembler does it either).

In C11 mode you can always override the default alignment:

Code: [Select]
#include <stdalign.h>
...
alignas(int) char string[] = "...";
...
3
Beginner questions / Re: Build process and PoMake
« Last post by Grincheux on Today at 04:58:09 pm »
I did not know the value to set and 99 was for anwering the TRUE value.
Thank you for the answer.
4
Beginner questions / Re: Build process and PoMake
« Last post by Pelle on Today at 04:55:35 pm »
Like many programs, the Pelle's C tools will return either EXIT_SUCCESS (0) or EXIT_FAILURE (1).
ERRORLEVEL 99 is way too high to catch anything. Change it to ERRORLEVEL 1 it will work fine...
5
FAQ / Re: Unreachable code
« Last post by frankie on Today at 12:12:30 am »
What is the exact warning text?
On which line? In the following line?
Code: [Select]
return crcspeed64little(dual ? crc64_table_little : crc64_table, crc,(void *)s, l);
It could also be a bug...
6
Beginner questions / Re: Alignment
« Last post by TimoVJL on Yesterday at 11:31:05 am »
NO, even msvc does that ?
7
Beginner questions / Alignment
« Last post by Grincheux on December 12, 2019, 08:59:13 pm »
Are we sure that strings are four bytes aligned when compiling in 64 bits?

Example:

char szNullString[] = "\0" ;
char szString1[] = "1" ;
char szString1[] = "12" ;
char szString1[] = "123" ;
char szString1[] = "1234" ;

is it equal to the following asm code?

szNullString Byte 0,0,0,0
szString1 BYTE "1",0,0,0
szString2 BYTE  "12",0,0
szString3 BYTE "123",0
szString4 Byte "1234",0,0,0,0
8
Beginner questions / Re: Build process and PoMake
« Last post by Grincheux on December 10, 2019, 08:22:07 pm »
I have created a ini file describing the compilers.
I have manually created a project file

My question is :

How can I detect an error in source file (.rc .asm or .c)
Does porc, poasm or pocc returns a code indicating a "complete failure".
I would like to use this as follow :

Code: [Select]
@ECHO OFF
C:\Program Files\PellesC\Bin\pocc.exe -std:C17 -Tx64-coff -arch:SSE2 -Ot -Ox -Ob2 -I"C:\Program Files\PellesC\Include\Win;C:\Program Files\PellesC\Include" -fp:precise -W2 -Ze -Zx -J "myEditor.c" -Fo"myEditor.obj"
IF ERRORLEVEL 99 GOTO FAILURE

C:\Program Files\PellesC\Bin\polink.exe -subsystem:windows -machine:x64 -release -largeaddressaware -LIBPATH:"C:\Program Files\PellesC\Lib\Win64;C:\Program Files\PellesC\Lib" @ResponseFile.rsp -out:"$EXE_FILE"

@ECHO NO errors found
@PAUSE
@EXIT
.
.
.
FAILURE:@ECHO Errors have been detected!
@PAUSE
@EXIT
9
FAQ / Re: Unreachable code
« Last post by Grincheux on December 10, 2019, 08:10:51 pm »
Ok Frankie, I had understood this but this is not always the case.
Specially this one :

Code: [Select]
uint64_t crc64speed(uint64_t crc, const void *s, const uint64_t l)
{
/* Quickly check if CRC table is initialized to little endian correctly. */
#ifndef CRC64SPEED_DUAL
    check_init(crc64_table, LITTLE1);
#else
    check_init(crc64_table_little, LITTLE1);
#endif
    return crcspeed64little(dual ? crc64_table_little : crc64_table, crc,(void *)s, l);
}
Quote
return crcspeed64little(dual ? crc64_table_little : crc64_table, crc,(void *)s, l);

https://github.com/mattsta/crcspeed
https://github.com/mattsta/crc64-compare
https://matt.sh/redis-crcspeed
10
FAQ / Re: Unreachable code
« Last post by frankie on December 10, 2019, 06:05:44 pm »
Unreachable, or dead, code is that code that will never be executed, and for this reason will not be emitted by the compiler.
These parts are normally generated when a conditional execution resolves to a constant comparison that allows the compiler to evaluate that the code will never execute during compilation. I.e.
Code: [Select]
    const a=2;    //This is a constant value
    ...
    if (a ==10)    //This condition will never be true. The code will be removed
    {
        printf("Dead code. Will never be executed!\");
    }

Another example is when there is code after a return statement:
Code: [Select]
void foo(void)
{
    printf("foo()\n");
    return;
    printf("Dead code. Will never be executed!\");
}

The warn is very useful if you put the code there by mistake.
Pages: [1] 2 3 ... 10