Jump to content

C++ proposition


Jief_Machak
 Share

823 posts in this topic

Recommended Posts

d:\projects\cloverbootloader\rEFIt_UEFI\Platform\Posix\strlen.cpp(27): error C2220: warning treated as error - no 'object' file generated
d:\projects\cloverbootloader\rEFIt_UEFI\Platform\Posix\strlen.cpp(27): warning C4311: 'type cast': pointer truncation from 'const char *' to 'unsigned long'
d:\projects\cloverbootloader\rEFIt_UEFI\Platform\Posix\strlen.cpp(27): warning C4302: 'type cast': truncation from 'const char *' to 'unsigned long'

Link to comment
Share on other sites

Now I am at home with GCC.

/Users/sergey/src/CloverHackyColor/rEFIt_UEFI/Platform/Posix/strlen.cpp: In function 'size_t strlen(const char*)':

/Users/sergey/src/CloverHackyColor/rEFIt_UEFI/Platform/Posix/strlen.cpp:31:24: error: comparison of integer expressions of different signedness: 'long int' and 'UINTN' {aka 'long long unsigned int'} [-Werror=sign-compare]

   31 |    if ( char_ptr - str > SIZE_T_MAX ) abort();

cc1plus: all warnings being treated as errors

 

Link to comment
Share on other sites

6 minutes ago, Jief_Machak said:

Time to try the gdb_launch and put a breakpoint on abort() or panic()

Did you get the commit "uintptr_t in strlen.cpp". I was to quick to solve the warning... cast to a signed type of SIZE_T_MAX doesn't work if SIZE_T_MAX is 8 bytes.

Working here, so it must be it.

How to delete my two commits?

Link to comment
Share on other sites

But Autogen.h should be regenerated after each header update.

What else?

ld: file not found: /Users/sergey/src/CloverHackyColor/Xcode/CloverX64/DerivedData/CloverX64/Build/Products/Debug/libCloverX64.a

Link to comment
Share on other sites

In practice, autogen.h almost never changes. Currently at least.

When refactoring, for example I changed a CHAR16* to XStringW, then I use the compiler to tell me what to change. So I do tons of compilation. Xcode put me right on the error. When use to it, hard to go back to only compile in command line... I think.

Link to comment
Share on other sites

9 hours ago, Download-Fritz said:

Print argument semantics are of course unaffected by the family of functions used. "%a" is ASCII, "%s" is UCS-2, always. It makes no sense to make argument interpretation different based on the destination type anyway.

I tried

  DBG("Test ascii=%a ucs-2=%s\n", "a string", L"Выход из подменю, обновление главного меню\n");
  DBG("Test ascii=%a ucs-2=%s\n", "a string", "Выход из подменю, обновление главного меню\n");
  DBG("Test ascii=%a ucs-2=%a\n", "a string", "Выход из подменю, обновление главного меню\n");

And I got :

1:719  1:594  Test ascii=a string ucs-2=KE>4 87 ?>4<5=N, >1=>2;5=85 3;02=>3> <5=N

1:721  0:002  Test ascii=a string ucs-2=����� ���������,���������� ������������
Ts si=aus2
Uioeolto tts
SmlTxE tts

1:724  0:002  Test ascii=a string ucs-2=Выход из подменю, обновление главного меню

So I don't know what %s expect, but obviously %s doesn't work with Ascii...Printf function ?

 

Anyway, will replace that by the printf implementation I provided, that is small (last time I tried it was 414 bytes on an arduino 16 bits!) and won't have that problem.

Link to comment
Share on other sites

I've compared AutoGen.c and AutoGen.h between a version from the 6th of January and today's version. The only change is when the name went from CLOVER to CLOVERX64.

So I can confirm that there is no need to regenerate regularly AutoGen.{c,h}, except for non-ordinary changes (like the name, or a new guid used). It's true that we have sometime to rebuild from scratch, but it's not because of AutoGen.

 

Screen Shot 2020-03-13 at 23.42.35.png

50 minutes ago, Slice said:

ld: file not found: /Users/sergey/src/CloverHackyColor/Xcode/CloverX64/DerivedData/CloverX64/Build/Products/Debug/libCloverX64.a

I was hoping this setting would be saved with the project. DerivedData has to be project relative. File menu -> Project settings -> Derived Data = Project-relative Location.

Screen Shot 2020-03-13 at 23.45.38.png

There is probably a better solution like a post-build step that would copy the lib to a specific location next to the project.

Link to comment
Share on other sites

47 minutes ago, Jief_Machak said:

I tried


  DBG("Test ascii=%a ucs-2=%s\n", "a string", L"Выход из подменю, обновление главного меню\n");
  DBG("Test ascii=%a ucs-2=%s\n", "a string", "Выход из подменю, обновление главного меню\n");
  DBG("Test ascii=%a ucs-2=%a\n", "a string", "Выход из подменю, обновление главного меню\n");

And I got :


1:719  1:594  Test ascii=a string ucs-2=KE>4 87 ?>4<5=N, >1=>2;5=85 3;02=>3> <5=N

1:721  0:002  Test ascii=a string ucs-2=����� ���������,���������� ������������
Ts si=aus2
Uioeolto tts
SmlTxE tts

1:724  0:002  Test ascii=a string ucs-2=Выход из подменю, обновление главного меню

So I don't know what %s expect, but obviously %s doesn't work with Ascii...Printf function ?

 

Anyway, will replace that by the printf implementation I provided, that is small (last time I tried it was 414 bytes on an arduino 16 bits!) and won't have that problem.

 

I'm positive they work correctly, because they all end up using the same function underneath. And also because there was no problem before, it worked perfectly fine to do such things. Why wouldn't you just use the printf builtin to the standard library for arduino avr compiler...?

Link to comment
Share on other sites

 Share

×
×
  • Create New...