Handmade Hero»Forums»Code
andre
12 posts
using Visual Studio for editing and build.bat
Edited by andre on
Hey folks,

i am trying to use visual studio for editing along with the build.bat.
i already tried to set up a makefile-project and set the paths to build.bat and to the build directory (my directory-setup is exactly the same as caseys) and then i imported the sources.
but i always get erros when building with multiple files and header-files, like "uint32 not declared".
can someone please tell me how i have to set up visual studio to work with the build.bat.!?

thanx!

bye
phil
Mārtiņš Možeiko
2559 posts / 2 projects
using Visual Studio for editing and build.bat
Did you add all cpp files to project? You shouldn't do that because Casey is compiling only one file for game dll - handmade.cpp. Other files are included in this cpp file, and they depend on previously included files. Compiling each cpp file individually will require you to adjust includes in them.
andre
12 posts
using Visual Studio for editing and build.bat
thanks! i understood that but it doesnt solve my problem:

i simply want to use visual studio for editing and use features like intelliSense, autocomplete ....
so i only want to point visual studio to the sources in w:\handmade\code
and tell VS to use build.bat

but that doesnt work. i get lots of errors

how can i do that??

bye
phil
Mārtiņš Možeiko
2559 posts / 2 projects
using Visual Studio for editing and build.bat
You need to explain more.
a) what error exactly are you getting?
b) where are you getting it (intellisense? build.bat? which file? which include?
andre
12 posts
using Visual Studio for editing and build.bat
ok, code is in W:\handmade\code
now i startup visual studio 2013 => new project => visual c++ => makefile project

name: code
location: W:\handmade
create subdir: NO

build command line: W:\handmade\code\build.bat
output for debugging: W:\build\win32_handmade.exe

now i have some visual studio files in dir "code" together with the sources and build.bat
code.v12.suo
code.vcxproj.filters
code.vcxproj
code.sdf
code.opensdf
code.sln

now visual studio does not "see" the sources => i tried to import them:

solution-explorer: right click on "source files" => add => existing item
selected all the sources (.cpp) and imported this way

solution-explorer: right click on "header files" => add => existing item
selected all the sources (.h) and imported this way

now evrything seems to be in the solution.


when i do this with day11 => build "code" => it works without errors

when i do this with day41 => i see errors:

for example in the code of handmade.cpp:
debug_platform_read_entire_file => is undefined

=> build "code" =>

1>------ Build started: Project: code, Configuration: Debug Win32 ------
1> handmade.cpp
1>w:\handmade\code\handmade.cpp(319): error C2220: warning treated as error - no 'object' file generated
1>w:\handmade\code\handmade.cpp(319): warning C4244: 'argument' : conversion from 'uint64' to 'memory_index', possible loss of data
1> win32_handmade.cpp
1>w:\handmade\code\win32_handmade.cpp(79): error C2220: warning treated as error - no 'object' file generated
1>w:\handmade\code\win32_handmade.cpp(79): warning C4018: '<' : signed/unsigned mismatch
1>w:\handmade\code\win32_handmade.cpp(86): warning C4018: '<' : signed/unsigned mismatch
1>w:\handmade\code\win32_handmade.cpp(707): warning C4244: 'argument' : conversion from 'uint64' to 'size_t', possible loss of data
1>w:\handmade\code\win32_handmade.cpp(736): warning C4244: 'argument' : conversion from 'uint64' to 'size_t', possible loss of data
1>w:\handmade\code\win32_handmade.cpp(1229): warning C4244: 'argument' : conversion from 'uint64' to 'SIZE_T', possible loss of data
1>C:\Program Files (x86)\MSBuild\Microsoft.Cpp\v4.0\V120\Microsoft.MakeFile.Targets(38,5): error MSB3073: The command "W:\handmade\code\build.bat" exited with code -1.
========== Build: 0 succeeded, 1 failed, 0 up-to-date, 0 skipped ==========


the same with day30 => build:


1>------ Build started: Project: code, Configuration: Debug Win32 ------
1> handmade.cpp
1> Creating library handmade.lib and object handmade.exp
1> win32_handmade.cpp
1>w:\handmade\code\win32_handmade.cpp(78): error C2220: warning treated as error - no 'object' file generated
1>w:\handmade\code\win32_handmade.cpp(78): warning C4018: '<' : signed/unsigned mismatch
1>w:\handmade\code\win32_handmade.cpp(85): warning C4018: '<' : signed/unsigned mismatch
1>w:\handmade\code\win32_handmade.cpp(677): warning C4244: 'argument' : conversion from 'uint64' to 'size_t', possible loss of data
1>w:\handmade\code\win32_handmade.cpp(706): warning C4244: 'argument' : conversion from 'uint64' to 'size_t', possible loss of data
1>w:\handmade\code\win32_handmade.cpp(1138): warning C4244: 'argument' : conversion from 'uint64' to 'SIZE_T', possible loss of data
1>C:\Program Files (x86)\MSBuild\Microsoft.Cpp\v4.0\V120\Microsoft.MakeFile.Targets(38,5): error MSB3073: The command "W:\handmade\code\build.bat" exited with code -1.
========== Build: 0 succeeded, 1 failed, 0 up-to-date, 0 skipped ==========
andre
12 posts
using Visual Studio for editing and build.bat
when i do this with day11 (only 1 header-file!) => build "code" => it works without errors

1>------ Build started: Project: code, Configuration: Debug Win32 ------
1> Ein Unterverzeichnis oder eine Datei mit dem Namen "..\..\build" existiert bereits.
1> Microsoft (R) C/C++ Optimizing Compiler Version 18.00.31101 for x86
1> Copyright (C) Microsoft Corporation. All rights reserved.
1>
1> win32_handmade.cpp
1> Microsoft (R) Incremental Linker Version 12.00.31101.0
1> Copyright (C) Microsoft Corporation. All rights reserved.
1>
1> /out:win32_handmade.exe
1> /debug
1> win32_handmade.obj
1> user32.lib
1> gdi32.lib
========== Build: 1 succeeded, 0 failed, 0 up-to-date, 0 skipped ==========
Mārtiņš Možeiko
2559 posts / 2 projects
using Visual Studio for editing and build.bat
Edited by Mārtiņš Možeiko on
It looks like you are compiling source to 32-bit code:
Microsoft (R) C/C++ Optimizing Compiler Version 18.00.31101 for x86
That's why there are warnings about "loosing data" when converting uint64_t to size_t (size_t on 32-bit platform is uint32_t). Casey is currently compiling source only as 64-bit code. So you'll need to either fix all those errors yourself, or adjust build.bat to compile source as 64-bit code.
andre
12 posts
using Visual Studio for editing and build.bat
ah ok! cool....thanks for the hint.
in my shell i use 64 bit. there is the batch file that starts on shell startup (like casey did it) and it calls
"C:\Program Files (x86)\Microsoft Visual Studio 12.0\VC\vcvarsall.bat" x64

how can i tell visual studio to use this 64 bit version of the compiler?

thanks!
phil
andre
12 posts
using Visual Studio for editing and build.bat
ok found it.
set compiler to 64 bit like here:
http://blogs.msdn.com/b/tolong/ar...-to-build-64-bit-application.aspx

and set correct working directory in properties.

now it works fine (thanks!!)
but i still see small errors in visual studio:


handmade.cpp:
================
internal loaded_bitmap
DEBUGLoadBMP(thread_context *Thread, debug_platform_read_entire_file *ReadEntireFile, char *FileName) { ...

debug_platform_read_entire_file => Error: identifier is undefined
debug_read_file_result => Error: identifier is undefined

... = ReadEntireFile(Thread, FileName);
=> <error-type> *ReadiEntireFile
Error: expression preceding parentheses of apparent call must have (pointer-to-) function type


handmade_platform.h:
==========================
debug_platform_free_file_memory => Error: identifier is undefined
debug_platform_read_entire_file => Error: identifier is undefined
debug_platform_write_entire_file => Error: identifier is undefined
Mārtiņš Možeiko
2559 posts / 2 projects
using Visual Studio for editing and build.bat
I currently don't understand what are you doing - are you building with Visual Studio IDE by creating C++ project, or with build.bat by creating makefile project. Because that link talks about how you configure IDE to build your Visual Studio project to 64-bit code. But initially you said you want to use makefile based project and call build.bat.

From errors it looks that you are building with Visual Studio IDE (by creating C++ project there). And errors are happening because it tries to compile all files added to project. As I explained above, Casey is compiling only handmade.cpp, and rest of cpp files should not be compiled individually (they are included in handmade.cpp file).
511 posts
using Visual Studio for editing and build.bat
mmozeiko
I currently don't understand what are you doing - are you building with Visual Studio IDE by creating C++ project, or with build.bat by creating makefile project. Because that link talks about how you configure IDE to build your Visual Studio project to 64-bit code. But initially you said you want to use makefile based project and call build.bat.

From errors it looks that you are building with Visual Studio IDE (by creating C++ project there). And errors are happening because it tries to compile all files added to project. As I explained above, Casey is compiling only handmade.cpp, and rest of cpp files should not be compiled individually (they are included in handmade.cpp file).


In other words remove the other cpp files (the ones that get #included from the main ones) from sources and add them as headers.
Mārtiņš Možeiko
2559 posts / 2 projects
using Visual Studio for editing and build.bat
Or use "Show All Files" view in Solution Explorer instead: https://i.stack.imgur.com/NmkhK.png
andre
12 posts
using Visual Studio for editing and build.bat
thanks!!

1.
i have set up a makefile project and building works with build.bat.
its a little bit confusing....i had to change the compiler inside visual studio to 64 bit to get rid of most of the errors. i guess visual studio intelliSense uses that.


2.
i removed all the other .cpp files from the visual studio project, only handmade.cpp ist left and the header-files. when i click "show all files" the excluded files have a red point so that seems to have worked.

i cleaned the project and building still works without problems, but there is still the error in handmade.cpp, see screenshot here:

https://www.dropbox.com/s/4hj7hay...6-02-09_visual-studio_is.png?dl=0

sorry for bothering :)

bye
phil
Mārtiņš Možeiko
2559 posts / 2 projects
using Visual Studio for editing and build.bat
Ah, the errors are intellisense errors, not build/compiler errors. That makes sense now.

Not sure there is something you can do about it. Intellisense uses internal - different compiler that regular cl.exe, so it expects your project to be in configuration it understands. Once you do something strange, it will error out. That is a common thing. I have learned not to trust intellisense in VS a very long time ago. You can use it if it helps you, but don't trust that code will compile if it says everything is fine, or other way around - that it won't compile because it thinks there is an error. Run a real compiler to get real errors/warnings.