[petsc-dev] another Microsoft compile issue
Barry Smith
bsmith at mcs.anl.gov
Tue Mar 11 15:46:14 CDT 2014
Yuck, but otherwise do we have a #if crappy microsoft compiler #else nice code.
Barry
On Mar 11, 2014, at 3:24 PM, Satish Balay <balay at mcs.anl.gov> wrote:
> On Tue, 11 Mar 2014, Jed Brown wrote:
>
>> Satish Balay <balay at mcs.anl.gov> writes:
>>
>>> On Tue, 11 Mar 2014, Jed Brown wrote:
>>>
>>>> Barry Smith <bsmith at mcs.anl.gov> writes:
>>>>
>>>>> const struct {PetscInt i,j; PetscScalar v;} entries[] = {{0,3,1.},{1,2,2.},{2,1,3.},{2,5,4.},{3,0,5.},{3,6,6.},{4,1,7.},{4,4,8.}};
>>>>>
>>>>> /home/sbalay/petsc.clone-2/bin/win32fe/win32fe cl -o ex151.o -c -DMPICH_SKIP_MPICXX -MT -GR -EHsc -Z7 -Zm200 -TP -I/home/sbalay/petsc.clone-2/include -I/home/sbalay/petsc.clone-2/arch-mswin-cxx-cmplx/include -I/cygdrive/c/Program\ Files/MPICH2/include `pwd`/ex151.c
>>>>> ex151.c
>>>>> C:\cygwin\home\sbalay\PETSC~2.CLO\src\mat\examples\tests\ex151.c(18) : error C2440: 'initializing' : cannot convert from 'const int' to 'const struct '
>>>>> No constructor could take the source type, or constructor overload resolution was ambiguous
>>>>
>>>> I don't know. Looks like valid C to me.
>>>>
>>>> Do we have a build using the MS C++ compiler? I hate to say it, but
>>>> they don't maintain their C compiler and may stop shipping it at any
>>>> time, so it's more important to ensure that PETSc builds with their C++.
>>>
>>> this is a c++ complex build. [I see c build is fine with this compiler].
>>
>> Ah, should have known. I don't have a decent solution.
>
> The following change appears to fix it. [currently windows build is broken elsewere]
>
> Satish
>
> ----------
>
> $ git diff
> diff --git a/src/mat/examples/tests/ex151.c b/src/mat/examples/tests/ex151.c
> index ac53b83..c476f3b 100644
> --- a/src/mat/examples/tests/ex151.c
> +++ b/src/mat/examples/tests/ex151.c
> @@ -15,8 +15,10 @@ static char help[] = "Tests MatPermute() in parallel.\n\n";
> #define __FUNCT__ "main"
> int main(int argc,char **argv)
> {
> - const struct {PetscInt i,j; PetscScalar v;} entries[] = {{0,3,1.},{1,2,2.},{2,1,3.},{2,5,4.},{3,0,5.},{3,6,6.},{4,1,7.},{4,4,8.}};
> - const PetscInt ixrow[5] = {4,2,1,0,3},ixcol[7] = {5,3,6,1,2,0,4};
> + const PetscInt entries_i[8] = { 0, 1, 2, 2, 3, 3, 4, 4 };
> + const PetscInt entries_j[8] = { 3, 2, 1, 5, 0, 6, 1, 4 };
> + const PetscScalar entries_v[8] = { 1.,2.,3.,4.,5.,6.,7.,8.};
> + const PetscInt ixrow[5] = {4,2,1,0,3},ixcol[7] = {5,3,6,1,2,0,4};
> Mat A,B;
> PetscErrorCode ierr;
> PetscInt i,rstart,rend,cstart,cend;
> @@ -34,8 +36,8 @@ int main(int argc,char **argv)
> ierr = MatGetOwnershipRange(A,&rstart,&rend);CHKERRQ(ierr);
> ierr = MatGetOwnershipRangeColumn(A,&cstart,&cend);CHKERRQ(ierr);
>
> - for (i=0; i<(PetscInt)(sizeof(entries)/sizeof(entries[0])); i++) {
> - ierr = MatSetValue(A,entries[i].i,entries[i].j,entries[i].v,INSERT_VALUES);CHKERRQ(ierr);
> + for (i=0; i<(PetscInt)(sizeof(entries_i)/sizeof(entries_i[0])); i++) {
> + ierr = MatSetValue(A,entries_i[i],entries_j[i],entries_v[i],INSERT_VALUES);CHKERRQ(ierr);
> }
> ierr = MatAssemblyBegin(A,MAT_FINAL_ASSEMBLY);CHKERRQ(ierr);
> ierr = MatAssemblyEnd(A,MAT_FINAL_ASSEMBLY);CHKERRQ(ierr);
More information about the petsc-dev
mailing list