Compile Error C2070 in dmusic.cpp using VS2012

Got a problem with OpenTTD? Find some help here.

Moderator: OpenTTD Developers

Post Reply
J R
Engineer
Engineer
Posts: 5
Joined: 07 Jul 2013 00:00

Compile Error C2070 in dmusic.cpp using VS2012

Post by J R »

Not sure I'm in the right forum for this. If not, please direct me to the right place.

I'm compiling the source using VS2012. I've read and implemented the suggestions in the "compiling" pages of the wiki. Doing this eliminated all but 14 errors. A bit of code correction eliminated ten syntax errors involving assignments (i.e.

Code: Select all

Something = {};
invalid).

I'm left with four "error C2070: 'unknown': illegal sizeof operand" messages in the dmusic.cpp compilation (at lines 977, 979, 1053 & 1058). The offending lines of code are below:

Code: Select all

				/* Region size depends on the number of wave loops. The size of the
				 * declared structure already accounts for one loop. */
				if (rgn->wave_sample.cbSize != 0) {
					i_size += sizeof(DMUS_REGION) - sizeof(DMUS_REGION::WLOOP) + sizeof(WLOOP) * rgn->wave_loops.size();
				} else {
					i_size += sizeof(DMUS_REGION) - sizeof(DMUS_REGION::WLOOP) + sizeof(WLOOP) * dls_file.waves[dls_file.pool_cues[rgn->wave.ulTableIndex].ulOffset].wave_loops.size();
}

Code: Select all

				/* The wave sample data will be taken from the region, if defined, otherwise from the wave itself. */
				if (rgn.wave_sample.cbSize != 0) {
					inst_region->WSMP = rgn.wave_sample;
					if (rgn.wave_loops.size() > 0) MemCpyT(inst_region->WLOOP, &rgn.wave_loops.front(), rgn.wave_loops.size());

					instrument = (char *)(inst_region + 1) - sizeof(DMUS_REGION::WLOOP) + sizeof(WLOOP) * rgn.wave_loops.size();
				} else {
					inst_region->WSMP = rgn.wave_sample;
					if (dls_file.waves[wave_id].wave_loops.size() > 0) MemCpyT(inst_region->WLOOP, &dls_file.waves[wave_id].wave_loops.front(), dls_file.waves[wave_id].wave_loops.size());

					instrument = (char *)(inst_region + 1) - sizeof(DMUS_REGION::WLOOP) + sizeof(WLOOP) * dls_file.waves[wave_id].wave_loops.size();
				}
I'm assuming that the

Code: Select all

sizeof(DMUS_REGION::WLOOP)
bit is the culprit, but I don't know what to do to correct this.

Anyone have any thoughts on this?

Thanks,
JR
Michi_cc
OpenTTD Developer
OpenTTD Developer
Posts: 619
Joined: 14 Jun 2004 23:27
Location: Berlin, Germany
Contact:

Re: Compile Error C2070 in dmusic.cpp using VS2012

Post by Michi_cc »

J R wrote:Anyone have any thoughts on this?
Don't trust unmaintained wiki pages too much. The only Visual Studio version that is regularly exercised is 2017 and it should compile the current sources unmodified as long as you use the matching solution file (..._vs141). Visual Studio 2015 might work, but anything else will not anymore.

-- Michael Lutz
J R
Engineer
Engineer
Posts: 5
Joined: 07 Jul 2013 00:00

Re: Compile Error C2070 in dmusic.cpp using VS2012

Post by J R »

Thank you. I'll try that and let you know if I succeed.
JR

"You can have ANY THING you want, but you can't have EVERY THING.
Choose carefully." Anonymous
J R
Engineer
Engineer
Posts: 5
Joined: 07 Jul 2013 00:00

Re: Compile Error C2070 in dmusic.cpp using VS2012

Post by J R »

Michael,

I got it all set up using VS2017. Compiled and got 408 C1083 errors "Cannot open include file: 'corecrt.h': No such file or directory (compiling source file ..\src\os\windows\{various filenames}.cpp)"

In the Error List, the Project for almost all errors is "openttd". A few show a Project of "settingsgen" or "strgen". All 408 errors show the File is "crtdefs.h".

I've searched through the downloaded source files and find no file named "corecrt.h" or "crtdefs.h". I've also searched the github file directory with no success.

Searched the forums for anything on "corecrt" and came up empty.

Am I missing something?

There are also three other errors. One is also a C1083 error "Cannot open include file: 'time.h': No such file or directory"
Project is "opentdd" and File is "script_date.cpp".

The other errors are MSB3073. Not worried about those until I clear up what should be the easy stuff.

Thanks for any help you may offer,
JR
JR

"You can have ANY THING you want, but you can't have EVERY THING.
Choose carefully." Anonymous
J R
Engineer
Engineer
Posts: 5
Joined: 07 Jul 2013 00:00

Re: Compile Error C2070 in dmusic.cpp using VS2012

Post by J R »

Argh!

Never mind. The .sln project file has the Win8.1 SDK selected and it should be the Win10 SDK. Upgrading the solution to the Win10 SDK fixes the problem and I got a successful build.

I think I'll invest a bit of time in updating the Wiki to spell out the current procedure for setting up a system to successfully compile in Win10 using VS2017. It just shouldn't be this frustrating to get started.

At least I got it to work.

Michael, thanks for getting me pointed in the right direction.

JR
JR

"You can have ANY THING you want, but you can't have EVERY THING.
Choose carefully." Anonymous
Alberth
OpenTTD Developer
OpenTTD Developer
Posts: 4763
Joined: 09 Sep 2007 05:03
Location: home

Re: Compile Error C2070 in dmusic.cpp using VS2012

Post by Alberth »

Please also throw away old stuff
Being a retired OpenTTD developer does not mean I know what I am doing.
Post Reply

Return to “OpenTTD Problems”

Who is online

Users browsing this forum: No registered users and 7 guests