Jief_Machak Posted February 18, 2020 Author Share Posted February 18, 2020 Thanks for letting me know. I'am changing that debug code. Will commit very soon. 1 Link to comment Share on other sites More sharing options...
Slice Posted February 18, 2020 Share Posted February 18, 2020 I already commit the cleanup. Look if this is correct. 1 Link to comment Share on other sites More sharing options...
Slice Posted February 20, 2020 Share Posted February 20, 2020 On 2/18/2020 at 3:42 PM, apianti said: What is up with no one knowing the difference between --i/++i and i--/i++? You should almost never be using i--/i++ unless you need the value before decrement/increment in the current expression. Otherwise, this emits at least two more instructions than the prefix operator does. Can you show asm codes for both cases? Where is the difference? Historically only i++ and --i had a sense because they came from PDP11 assembler where there are instruction like MOV (R1)+,R2 MOV R3, -(SP) So C languages is very close to those machine codes. Intel codes are different. Link to comment Share on other sites More sharing options...
Slice Posted February 20, 2020 Share Posted February 20, 2020 I made windows compilation almost working but d:\projects\clover\rEFIt_UEFI\Platform\BdsConnect.cpp(314): error C3861: __typeof__: идентификатор не найден (name not found) What is the way for workaround? Link to comment Share on other sites More sharing options...
Slice Posted February 20, 2020 Share Posted February 20, 2020 Next problem is d:\projects\clover\MdePkg\Include\Base.h(48): error C2220: предупреждение обработано как ошибка - файл "object" не создан d:\projects\clover\MdePkg\Include\Base.h(48): warning C4804: /: небезопасное использование типа "bool" в операции d:\projects\clover\MdePkg\Include\Base.h(49): warning C4804: /: небезопасное использование типа "bool" в операции d:\projects\clover\MdePkg\Include\Base.h(50): warning C4804: /: небезопасное использование типа "bool" в операции d:\projects\clover\MdePkg\Include\Base.h(51): warning C4804: /: небезопасное использование типа "bool" в операции d:\projects\clover\MdePkg\Include\Base.h(52): warning C4804: /: небезопасное использование типа "bool" в операции d:\projects\clover\MdePkg\Include\Base.h(53): warning C4804: /: небезопасное использование типа "bool" в операции d:\projects\clover\MdePkg\Include\Base.h(54): warning C4804: /: небезопасное использование типа "bool" в операции How it is supposed to work in VS2017? O, yes, it works ic C but not in C++. Link to comment Share on other sites More sharing options...
Jief_Machak Posted February 20, 2020 Author Share Posted February 20, 2020 Did you solve “typeof” problem ? Could you share your compilation settings, so I can compile on my computer ? Maybe commit in a branch ? Link to comment Share on other sites More sharing options...
Slice Posted February 20, 2020 Share Posted February 20, 2020 I committed cbuild.bat to make VS compilation and one example to resolve __typeof__. As well I disabled warning 4804 in Base.h. That's all in the moment. About compilation I install fresh Python3.8.1 for all users (run as administrator) and clean environment variables. I have to say that new BaseTools is not working. The working one is old provided with Clover. Can we make *HandleType = static_cast<UINT32*>(AllocatePool(*HandleCount * sizeof(UINT32))); for all compilers? Link to comment Share on other sites More sharing options...
Jief_Machak Posted February 20, 2020 Author Share Posted February 20, 2020 Typeof is nicer, I think, because if the type change, no need to change the cast. if VS had really no typeof at all, I can always change all these casts to explicite ones. le me have a look in 2/3 hours. Link to comment Share on other sites More sharing options...
Slice Posted February 20, 2020 Share Posted February 20, 2020 Looks like typeof is not supported in VS https://stackoverflow.com/questions/1540086/how-to-typeof-in-c Link to comment Share on other sites More sharing options...
Jief_Machak Posted February 20, 2020 Author Share Posted February 20, 2020 Typeof is nicer, I think, because if the type change, no need to change the cast. if VS had really no typeof at all, I can always change all these casts to explicite ones. le me have a look in 2/3 hours. Link to comment Share on other sites More sharing options...
Slice Posted February 20, 2020 Share Posted February 20, 2020 decltype(a) is the same as __typeof__(a) ? Link to comment Share on other sites More sharing options...
Jief_Machak Posted February 20, 2020 Author Share Posted February 20, 2020 typeof is a (gnu) extension. Decltype is standardized and only valid for C++. now we have switched, we should do a massive replacement of typeof by decltype. Link to comment Share on other sites More sharing options...
Slice Posted February 20, 2020 Share Posted February 20, 2020 ProcessorBind.h should be // typedef unsigned short CHAR16; typedef wchar_t CHAR16; Yes? Link to comment Share on other sites More sharing options...
Jief_Machak Posted February 20, 2020 Author Share Posted February 20, 2020 typeof is a (gnu) extension. Decltype is standardized and only valid for C++. now we have switched, we should do a massive replacement of typeof by decltype. Yes, in c++, littéral are wchar_t. In our case it’s compatible with unsigned short, but not always. That’s why char16* s = L”a string”; doesn’t work. Link to comment Share on other sites More sharing options...
Slice Posted February 20, 2020 Share Posted February 20, 2020 Instead of char16* s = L”a string”; should be char16 s[] = L”a string”; but then check for usage. Link to comment Share on other sites More sharing options...
Slice Posted February 20, 2020 Share Posted February 20, 2020 For example #ifdef FIRMWARE_REVISION CONST CHAR16 gFirmwareRevisionM[] = FIRMWARE_REVISION; CONST CHAR16 *gFirmwareRevision = &gFirmwareRevisionM[0]; #else CONST CHAR16 *gFirmwareRevision = NULL; #endif Link to comment Share on other sites More sharing options...
Slice Posted February 20, 2020 Share Posted February 20, 2020 This way? #ifdef _MSC_VER #define __typeof__(x) decltype(x) #endif Link to comment Share on other sites More sharing options...
Slice Posted February 20, 2020 Share Posted February 20, 2020 A simple workaround for type cast but not universal void FreePool(const wchar_t * A) { FreePool((VOID*)A); } Will be better to make replaces where needed. Link to comment Share on other sites More sharing options...
Jief_Machak Posted February 20, 2020 Author Share Posted February 20, 2020 31 minutes ago, Slice said: Instead of char16* s = L”a string”; should be char16 s[] = L”a string”; but then check for usage. Sorry, I was with my phone 'char16' doesn't exist. Even when you compile with short wchar option, unsigned short and wchar_t are considered different by c++, even though they are technically the same. So unsigned short *s = L”a string”; doesn't compile. Nor do unsigned short s[] = L”a string”. It has to be wchar_t. But because edk define CHAR16, I though easier to change that type. CONST CHAR16* gFirmwareRevision = FIRMWARE_REVISION; should work because CHAR16 is now wchar_t. Link to comment Share on other sites More sharing options...
Jief_Machak Posted February 20, 2020 Author Share Posted February 20, 2020 I'm launching Windows to compile with VS2017. When the command you use to build, just cbuild.bat with no args ? Link to comment Share on other sites More sharing options...
Slice Posted February 20, 2020 Share Posted February 20, 2020 Yes cbuild.bat without args because default values tuned for me. You may use buildmc.bat with parameters. See inside it. OEMPath should not be CONST CHAR16* because it used as args for EDK2 functions required CHAR16* Link to comment Share on other sites More sharing options...
Jief_Machak Posted February 20, 2020 Author Share Posted February 20, 2020 5 minutes ago, Slice said: OEMPath should not be CONST CHAR16* because it used as args for EDK2 functions required CHAR16* In the version I've committed, OEMPath is const, so it's already working like that. But I had to update function definition to add CONST when needed on IN parameter. I don't understand why edkII didn't put CONST on all their IN parameter. To not interfere with compilation of C module, I've added JCONST, which is defined as CONST only for clover compilation. Link to comment Share on other sites More sharing options...
Slice Posted February 20, 2020 Share Posted February 20, 2020 VOID AddListElement(IN OUT VOID ***ListPtr, IN OUT UINTN *ElementCount, IN VOID *NewElement) in the lib.cpp is looks wrong. Should be switch to list.cpp? Link to comment Share on other sites More sharing options...
Slice Posted February 20, 2020 Share Posted February 20, 2020 I pushed my current changes for your convenience to compile with VS. Link to comment Share on other sites More sharing options...
Jief_Machak Posted February 20, 2020 Author Share Posted February 20, 2020 When I try to compile on Windows, I got : Building architecture (X64) ... Building Clover (X64) ... Generating C:\Users\jief\Documents\CloverBootloader\Version.h 'build' is not recognized as an internal or external command, operable program or batch file. !!! Error while building !!! I saw that when I tried MSVC few weeks ago, but can't remember. Don't you know how to fix this ? Link to comment Share on other sites More sharing options...
Recommended Posts