I'm trying to install reactive-banana, wx, wxcore in cabal sandbox. When cabal install --only-dependencies is run following error message is given:
src\cpp\eljlistctrl.cpp: In function 'int ListCmp(long int, long int, long int)':
src\cpp\eljlistctrl.cpp:16:23: warning: cast to pointer from integer of different size [-Wint-to-pointer-cast]
src\cpp\eljlistctrl.cpp:16:53: warning: cast to pointer from integer of different size [-Wint-to-pointer-cast]
src\cpp\eljlistctrl.cpp: In function 'bool wxListCtrl_SortItems(wxListCtrl*, void*, void*)':
src\cpp\eljlistctrl.cpp:478:41: error: cast from 'EiffelSort* {aka _EiffelSort*}' to 'long int' loses precision [-fpermissive]
src\cpp\eljlistctrl.cpp:478:44: error: invalid conversion from 'int (*)(long int, long int, long int)' to 'wxListCtrlCompare {aka int (*)(long long int, long long int, long long int)}' [-fpermissive]
C:\wxWidgets-3.0.2\include/wx/msw/listctrl.h:342:10: error: initializing argument 1 of 'bool wxListCtrl::SortItems(wxListCtrlCompare, wxIntPtr)' [-fpermissive]
What is wrong and how to solve this?
The code in this file just seems to be wrong and uses 32 bit types even in what looks like 64 bit build. Unless it was fixed in later versions, the only solution would be to build it in 32 bits, i.e. use a 32 bit Haskell installation.
Related
I'm trying to get Talking-head-Generation-with-Rhythmic-Head-Motion to work inside Google Colab.
I just start a new Notebook and executed this:
!pip3 install dominate
!git clone https://github.com/lelechen63/Talking-head-Generation-with-Rhythmic-Head-Motion
cd Talking-head-Generation-with-Rhythmic-Head-Motion
!python scripts/download_flownet2.py
and got this:
/usr/local/lib/python3.7/dist-packages/torch/include/torch/csrc/api/include/torch/nn/modules/conv.h: In instantiation of ‘void torch::nn::ConvNdImpl<D, Derived>::reset() [with long unsigned int D = 2; Derived = torch::nn::Conv2dImpl]’:
/usr/local/lib/python3.7/dist-packages/torch/include/torch/csrc/api/include/torch/optim/sgd.h:49:17: required from here
/usr/local/lib/python3.7/dist-packages/torch/include/torch/csrc/api/include/torch/nn/modules/conv.h:77:21: error: could not convert ‘c10::nullopt’ from ‘const c10::nullopt_t’ to ‘c10::optional<c10::MemoryFormat>’
torch::empty(weight_sizes));
~~~~~~~~~~~~^~~~~~~~~~~~~~
/usr/local/lib/python3.7/dist-packages/torch/include/torch/csrc/api/include/torch/nn/modules/conv.h:85:21: error: could not convert ‘c10::nullopt’ from ‘const c10::nullopt_t’ to ‘c10::optional<c10::MemoryFormat>’
torch::empty(weight_sizes));
~~~~~~~~~~~~^~~~~~~~~~~~~~
/usr/local/lib/python3.7/dist-packages/torch/include/torch/csrc/api/include/torch/nn/modules/conv.h:89:59: error: could not convert ‘c10::nullopt’ from ‘const c10::nullopt_t’ to ‘c10::optional<c10::MemoryFormat>’
bias = this->register_parameter("bias", torch::empty({options.out_channels()}));
~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~
/usr/local/lib/python3.7/dist-packages/torch/include/torch/csrc/api/include/torch/nn/modules/conv.h: In instantiation of ‘void torch::nn::ConvNdImpl<D, Derived>::reset() [with long unsigned int D = 1; Derived = torch::nn::Conv1dImpl]’:
/usr/local/lib/python3.7/dist-packages/torch/include/torch/csrc/api/include/torch/optim/sgd.h:49:17: required from here
/usr/local/lib/python3.7/dist-packages/torch/include/torch/csrc/api/include/torch/nn/modules/conv.h:77:21: error: could not convert ‘c10::nullopt’ from ‘const c10::nullopt_t’ to ‘c10::optional<c10::MemoryFormat>’
torch::empty(weight_sizes));
~~~~~~~~~~~~^~~~~~~~~~~~~~
/usr/local/lib/python3.7/dist-packages/torch/include/torch/csrc/api/include/torch/nn/modules/conv.h:85:21: error: could not convert ‘c10::nullopt’ from ‘const c10::nullopt_t’ to ‘c10::optional<c10::MemoryFormat>’
torch::empty(weight_sizes));
~~~~~~~~~~~~^~~~~~~~~~~~~~
/usr/local/lib/python3.7/dist-packages/torch/include/torch/csrc/api/include/torch/nn/modules/conv.h:89:59: error: could not convert ‘c10::nullopt’ from ‘const c10::nullopt_t’ to ‘c10::optional<c10::MemoryFormat>’
bias = this->register_parameter("bias", torch::empty({options.out_channels()}));
~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~
error: command 'x86_64-linux-gnu-gcc' failed with exit status 1
Looks like it is trying to compile it after downloading, and failed.
Anyone knows how to make it work?
Or should I not be using Google Colab, and something else - like a VM or in a real Linux box?
I know there are similar questions and I don't know the best wording for this one.
I find it a little ironic that the reason for the code analysis warning in the first place was that it told me to use gsl::narrow into two instances:
Instance 1:
auto* pCell1 = gsl::narrow<CGridCellBase*>(lParam1);
auto* pCell2 = gsl::narrow<CGridCellBase*>(lParam2);
Compilation error:
6>D:\My Libraries\GSL-main\include\gsl\util(105,1): error C2440: 'static_cast': cannot convert from 'U' to 'T'
6> with
6> [
6> U=LPARAM
6> ]
6> and
6> [
6> T=CGridCellBase *
6> ]
6>D:\My Libraries\GSL-main\include\gsl\util(105,12): message : Conversion from integral type to pointer type requires reinterpret_cast, C-style cast or function-style cast
Instance 2:
auto* pItem = gsl::narrow<NM_GRIDVIEW*>(pNotifyStruct);
Compilation error:
6>D:\My Libraries\GSL-main\include\gsl\narrow(58,1): error C2440: 'static_cast': cannot convert from 'const T' to 'U'
6> with
6> [
6> T=NM_GRIDVIEW *
6> ]
6> and
6> [
6> U=NMHDR *
6> ]
6>D:\My Libraries\GSL-main\include\gsl\narrow(58,9): message : Types pointed to are unrelated; conversion requires reinterpret_cast, C-style cast or function-style cast
Those messages are telling me to do the reverse:
Conversion from integral type to pointer type requires reinterpret_cast, C-style cast or function-style cast
Types pointed to are unrelated; conversion requires reinterpret_cast, C-style cast or function-style cast
Going around in circles! Given the situation then, am I to understand that the correct way forward is:
Use reinterpret_cast and...
Add appropriate prama warning to suppress the warning.
Correct?
You can't (and shouldn't try to) use anything other than a reinterpret_cast to convert between a pointer and a non-pointer, or between pointers to different (unrelated) types. The gsl::narrow function is just a 'fancy' version of static_cast: Understanding gsl::narrow implementation.
Further, when writing programs that use the WinAPI or MFC, it is virtually impossible to completely avoid casting between pointer and non-pointer types; notably, many of the message handling routines take a pointer to some data or other as their lParam argument (the LPARAM type is defined as either __int64 or int, depending on the target platform).
So, your suggestion is, IMHO, the best option:
Use reinterpret_cast and...
Add appropriate pragma warning to suppress the warning.
However, you will most likely need to add that #pragma... directive in many places in your code. So, what you can do is to create a 'helper' (or wrapper) cast of your own, which you can then use throughout your code.
For example, you can add the following to your "stdafx.h" (or "pch.h") file (or to any header that is included wherever the cast is needed):
template<typename T, typename U> static T inline pointer_cast(U src) noexcept
{
static_assert(sizeof(T) >= sizeof(U), "Invalid pointer cast"); // Check sizes!
__pragma(warning(suppress:26490)) // Note: no semicolon after this expression!
return reinterpret_cast<T>(src);
}
You can then use that pointer_cast and avoid having to add the pragma each time. Here's a typical example, using a potential message handler for the WM_NOTIFY message in a custom dialog box class:
BOOL MyDialog::OnNotify(WPARAM wParam, LPARAM lParam, LRESULT *pResult)
{
NMHDR* pHdr = pointer_cast<NMHDR*>(lParam);
switch (pHdr->code) {
//... remaining code ...
Note: on the use of the __pragma() directive (rather than #pragma), see here.
I am tring to build an R package with Rcpp using Rstudio. When I click "install and restart", Rstudio outputs hundreds of warning information and I cannot easily find the error information. I tried to find out reason to avoid the warning information but failed. It seems the warnings are from Rcpp package. BTW, the package can still work.
The below is the additional options for R CMD INSTALL
--no-multiarch --with-keep.source
The information can be replicated using the below commands
library(devtools) # author version: 2.3.0, use install.packages("devtools") first
install_github("GeneticAnalysisinBiobanks/GRAB", INSTALL_opts=c("--no-multiarch")) # The INSTALL_opts is required in Windows OS.
My working environment:
> sessionInfo()
R version 4.1.0 (2021-05-18)
Platform: x86_64-w64-mingw32/x64 (64-bit)
Running under: Windows 10 x64 (build 19042)
Matrix products: default
locale:
[1] LC_COLLATE=Chinese (Simplified)_China.936 LC_CTYPE=Chinese (Simplified)_China.936
[3] LC_MONETARY=Chinese (Simplified)_China.936 LC_NUMERIC=C
[5] LC_TIME=Chinese (Simplified)_China.936
attached base packages:
[1] stats graphics grDevices utils datasets methods base
other attached packages:
[1] devtools_2.4.2 usethis_2.0.1
loaded via a namespace (and not attached):
[1] rstudioapi_0.13 magrittr_2.0.1 pkgload_1.2.1 R6_2.5.0
[5] rlang_0.4.11 fastmap_1.1.0 tools_4.1.0 pkgbuild_1.2.0
[9] sessioninfo_1.1.1 cli_3.0.0 withr_2.4.2 ellipsis_0.3.2
[13] remotes_2.4.0 rprojroot_2.0.2 lifecycle_1.0.0 crayon_1.4.1
[17] processx_3.5.2 purrr_0.3.4 callr_3.7.0 fs_1.5.0
[21] ps_1.6.0 curl_4.3.1 testthat_3.0.4 memoise_2.0.0
[25] glue_1.4.2 cachem_1.0.5 compiler_4.1.0 desc_1.3.0
[29] prettyunits_1.1.1
The below include the warning information when I install and restart the package.
In file included from C:/Users/wenjianb/Documents/R/win-library/4.1/Rcpp/include/RcppCommon.h:118,
from C:/Users/wenjianb/Documents/R/win-library/4.1/RcppArmadillo/include/RcppArmadilloForward.h:26,
from C:/Users/wenjianb/Documents/R/win-library/4.1/RcppArmadillo/include/RcppArmadillo.h:31,
from RcppExports.cpp:4:
C:/Users/wenjianb/Documents/R/win-library/4.1/Rcpp/include/Rcpp/routines.h: In function 'const char* Rcpp::type2name(SEXP)':
C:/Users/wenjianb/Documents/R/win-library/4.1/Rcpp/include/Rcpp/routines.h:70:73: warning: cast between incompatible function types from 'DL_FUNC' {aka 'void* (*)()'} to 'Fun' {aka 'const char* (*)(SEXPREC*)'} [-Wcast-function-type]
#define GET_CALLABLE(__FUN__) (Fun) R_GetCCallable( "Rcpp", __FUN__ )
^
C:/Users/wenjianb/Documents/R/win-library/4.1/Rcpp/include/Rcpp/routines.h:74:26: note: in expansion of macro 'GET_CALLABLE'
static Fun fun = GET_CALLABLE("type2name");
^~~~~~~~~~~~
C:/Users/wenjianb/Documents/R/win-library/4.1/Rcpp/include/Rcpp/routines.h: In function 'long unsigned int Rcpp::internal::enterRNGScope()':
C:/Users/wenjianb/Documents/R/win-library/4.1/Rcpp/include/Rcpp/routines.h:70:73: warning: cast between incompatible function types from 'DL_FUNC' {aka 'void* (*)()'} to 'Fun' {aka 'long unsigned int (*)()'} [-Wcast-function-type]
#define GET_CALLABLE(__FUN__) (Fun) R_GetCCallable( "Rcpp", __FUN__ )
^
C:/Users/wenjianb/Documents/R/win-library/4.1/Rcpp/include/Rcpp/routines.h:81:30: note: in expansion of macro 'GET_CALLABLE'
static Fun fun = GET_CALLABLE("enterRNGScope");
^~~~~~~~~~~~
C:/Users/wenjianb/Documents/R/win-library/4.1/Rcpp/include/Rcpp/routines.h: In function 'long unsigned int Rcpp::internal::exitRNGScope()':
C:/Users/wenjianb/Documents/R/win-library/4.1/Rcpp/include/Rcpp/routines.h:70:73: warning: cast between incompatible function types from 'DL_FUNC' {aka 'void* (*)()'} to 'Fun' {aka 'long unsigned int (*)()'} [-Wcast-function-type]
#define GET_CALLABLE(__FUN__) (Fun) R_GetCCallable( "Rcpp", __FUN__ )
^
C:/Users/wenjianb/Documents/R/win-library/4.1/Rcpp/include/Rcpp/routines.h:87:30: note: in expansion of macro 'GET_CALLABLE'
static Fun fun = GET_CALLABLE("exitRNGScope");
^~~~~~~~~~~~
C:/Users/wenjianb/Documents/R/win-library/4.1/Rcpp/include/Rcpp/routines.h: In function 'long unsigned int Rcpp::internal::beginSuspendRNGSynchronization()':
C:/Users/wenjianb/Documents/R/win-library/4.1/Rcpp/include/Rcpp/routines.h:70:73: warning: cast between incompatible function types from 'DL_FUNC' {aka 'void* (*)()'} to 'Fun' {aka 'long unsigned int (*)()'} [-Wcast-function-type]
#define GET_CALLABLE(__FUN__) (Fun) R_GetCCallable( "Rcpp", __FUN__ )
^
The other warnings are all similar to the above.
Thank you all in advance.
Wenjian
Arduino: 1.6.9 (Windows 10), Board: "Arduino Mega ADK"
In file included from C:\Users\Disheet\Downloads\humanoid_1\humanoid_1.ino:1:0:
C:\Users\Disheet\Documents\Arduino\libraries\ax12v2/ax12.h:66:23: error: conflicting declaration 'typedef unsigned char boolean'
typedef unsigned char boolean;
^
In file included from sketch\humanoid_1.ino.cpp:1:0:
C:\Program Files (x86)\Arduino\hardware\arduino\avr\cores\arduino/Arduino.h:117:14: error: 'boolean' has a previous declaration as 'typedef bool boolean'
typedef bool boolean;
^
C:\Users\Disheet\Downloads\humanoid_1\humanoid_1.ino: In function 'void setup()':
humanoid_1:5: error: 'SetPosition' was not declared in this scope
SetPosition(1,0);////id,posiotin 0-1023
^
C:\Users\Disheet\Downloads\humanoid_1\humanoid_1.ino: In function 'void loop()':
humanoid_1:13: error: 'SetPosition' was not declared in this scope
SetPosition(1,512);
^
Multiple libraries were found for "ax12.h"
Used: C:\Users\Disheet\Documents\Arduino\libraries\ax12v2
Not used: C:\Users\Disheet\Documents\Arduino\libraries\Bioloid
exit status 1
'SetPosition' was not declared in this scope
This report would have more information with
"Show verbose output during compilation"
option enabled in File -> Preferences.
You'll need to find typedef unsigned char boolean; in your library and change it to match the version in Arduino.h.
boolean is already a typedef in Arduino.h, and it is a bool ,not unsigned char.
In the AX12 library search for this:
https://github.com/7Robot/Arduino/blob/master/AX12/libraries/ax12/ax12.h#L66
And change it to typedef bool boolean;.
This was updated a while ago, so your IDE version is newer than the AX12 library.
ostream &stream;
stream.write(SomeUnsignedCharStar, intSize);
error C2664 cannot convert parameter 1 from const unsigned char * to const char *
Is there an overload write for const unsigned char *?
I do not want to change SomeUnsignedCharStar because it is everywhere in the legacy code I inherited. This was compiled on VC6 with no complain. I am slowly upgrading the code to VS2003 and then VS2010 evantually.
What is the easiest and cleanest fix?
You can cast this without any issues. Strict aliasing allows casting pointers between unsigned and signed versions of the same type, as well as casting from any type to const char*, so you're safe here.