Jump to content

C++ proposition


Jief_Machak
 Share

823 posts in this topic

Recommended Posts

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

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

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

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

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

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

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

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

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

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

 Share

×
×
  • Create New...