0
votes

While migrating from Visual studio 2013 to Visual studio 2019 compiler I have got below error. Please help me in fixing the same.

I have declared the function in the header file (.h) below:

#ifndef CSAHCCOMPOSEDITEM_H
#define CSAHCCOMPOSEDITEM_H

#ifdef _UTEST
class CsaHcDICOMComposerTester;
#endif

class EXP_IMP_HcDicComp CsaHcComposedItem
{
#ifdef _UTEST
friend class CsaHcDICOMComposerTester;
#endif

public:

enum CsaHcComposedItemType
{
CISegment,
CIPage,
CILayout,
CIPageBracket,

CIPrintJobBracket,

CIDummy
};

CsaHcComposedItem
(bool &status, CsaHcComposedItemType type_in);

CsaHcComposedItem
();

CsaHcComposedItem a
(const CsaHcComposedItem& compObj_in);

CsaHcComposedItem& operator=
(const CsaHcComposedItem& compObj_in);

~CsaHcComposedItem();

bool operator==
(const CsaHcComposedItem& ci_in);

private: // attributes

CsaHcComposedItemType
myType;
CsaHcBasicFilmSession
*myBFS;
CsaHcBasicFilmBox
*myBFB;
CsaHcBasicImageBox
*myBIB;
CsaDib  *myDib;
BYTE *myPixelArray;
};

#endif // CSAHCCOMPOSEDITEM_H
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

And cpp file contains the definition for the constructor.

//pusedo code

CsaHcComposedItem::CsaHcComposedItem(bool &status_out,
// Return status of the construcor
CsaHcComposedItemType type_in)
// Composed item type
: myType(type_in), // error shown for this line (70)
myBFS(NULL), //line71
myBFB(NULL),
myBIB(NULL),
myDib(NULL),
myPixelArray(NULL)
{
.....
}

Error:

1.CsaHcComposedItem.cpp(70): error C2761: '{ctor}': redeclaration of member is not allowed 2.CsaHcComposedItem.cpp(70): error C2059: syntax error: ':' 3.CsaHcComposedItem.cpp(70): error C2065: 'type_in': undeclared identifier 4.CsaHcComposedItem.cpp(70): error C4430: missing type specifier - int assumed. Note: C++ does not support default-int 5.CsaHcComposedItem.cpp(71): error C4430: missing type specifier - int assumed. Note: C++ does not support default-int 6.CsaHcComposedItem.cpp(72): error C4430: missing type specifier - int assumed. Note: C++ does not support default-int 7.CsaHcComposedItem.cpp(73): error C4430: missing type specifier - int assumed. Note: C++ does not support default-int 8.CsaHcComposedItem.cpp(74): error C4430: missing type specifier - int assumed. Note: C++ does not support default-int 9.CsaHcComposedItem.cpp(75): error C4430: missing type specifier - int assumed. Note: C++ does not support default-int 10.CsaHcComposedItem.cpp(78): error C2448: 'myPixelArray': function-style initializer appears to be a function definition

2
You lack includes in the header to various types that you have pointers to. At least forward declare them.ALX23z
sorry I couldn't understand.Ranjan V
E.g. CsaHcBasicFilmSession is not declared in the .h file - thus it shouldn't compile.ALX23z
Please provide a minimal reproducible example with focus on the minimalAlan Birtles
can't reproduce any issues with the posted code: godbolt.org/z/U35nyYAlan Birtles

2 Answers

0
votes

That source is compiled without error in VS2019(16.4.5)

I compiled with these declarations


#include <Windows.h>

#define EXP_IMP_HcDicComp

using CsaHcBasicFilmSession = int;
using CsaHcBasicFilmBox = int;
using CsaHcBasicImageBox = int;
using CsaDib = int;

enter image description here

0
votes

Issue is fixed, below line of code was not commented in my cpp file, after commenting it worked.