Handmade Hero»Forums»Code
Ville Penttinen
8 posts
Using VS instead of a Text Editor
I posted how I set up VS to compile while debugging a while back.

You can find the post here.

I'm still using it and it's working reasonably well. It does require slightly more work initially but once you've set it up it's really no different. Except you have to use a different binding to rebuild while running than normally.
17 posts
Using VS instead of a Text Editor
Edited by mallardz on Reason: I'm an idiot.
Thanks a lot Maldion, that looks like the perfect setup, once it's working.

EDIT: I'm an idiot and screwed up the external tool command syntax. Hopefully I should be able to sort it out from here.

[strike]Unfortunately I've messed up somewhere and am struggling to solve it. Essentially when I press the shortcut keys, the output window is highlighted, but nothing happens, no output is printed, no files are created. I'm sure it's something really basic, but the problem is VS is not giving me any feedback, maybe:

- visual studio could not find the build_dll.bat?
- the file paths in my bat are wrong?
- my project setup is wrong?

I was wondering if you knew how I could debug this? Make it so that VS or a console or something would throw an error or two if things are in the wrong place? Any suggestions welcome!

EDIT - for starters if I have: echo hello in my bat file, should that be outputted to the VS Output window when run? (I've ticked Use Output window.)[/strike]
Ameen Sayegh
51 posts
Using VS instead of a Text Editor
thank you a lot this is very helpful

but what is this syntax I can't find the documentation and I can't search it because of this square brackets

basically I want to use System.Random class but there is no static function that I can call
Ameen Sayegh
51 posts
Using VS instead of a Text Editor
Edited by Ameen Sayegh on Reason: clarifying the question
when debugging, does anyone know how visual studio can tell what the name of the PDB file for handmade_tmp.dll is to load symbols from?

because if you think about it this macro will generate different PDB file name each time?
It is working anyway but I'm just wondering
Mārtiņš Možeiko
2559 posts / 2 projects
Using VS instead of a Text Editor
MSDN documentation on cl/link arguments is pretty good, use it:
https://msdn.microsoft.com/en-us/library/9wst99a9.aspx
https://msdn.microsoft.com/en-us/library/kwx19e36.aspx
Ameen Sayegh
51 posts
Using VS instead of a Text Editor
thank you for the replay

my question is little ambiguous
I meant when I'm debugging the application and when it load handmade_tmp.dll how visual studio know what is the name of pdb file to open since the dll and pdb have different name
Roderic Bos
70 posts
Using VS instead of a Text Editor
The PDB is an option supplied to the linker, so probably the linker sets this filename somewhere in the dll and exe.

I just opened the .dll in notepad and searched for .pdb and saw my specific path in there (With the guid in the name). So every link adds the path to the debug pdb for the specific development machine.
Mārtiņš Možeiko
2559 posts / 2 projects
Using VS instead of a Text Editor
Oh.
DLL file has path to pdb file embedded inside. If you would open DLL file in hex editor you should be able to see it.
Cesar Peixoto
7 posts
Using VS instead of a Text Editor
Edited by Cesar Peixoto on
Hey guys, I arrived late and I'm stuck in this place, day 15.
Unfortunately, the files shared by kirbasin and frkn are offline.
One would again share the project files in Visual Studio, making a big favor!? !!!
I appreciate the help.
Kirill Basin
6 posts
Using VS instead of a Text Editor
Edited by Kirill Basin on
Here you go, these are from day 80+, but I don't think there were any breaking changes.

UPDATE: Forum doesn't show attachments, here's a link to my Dropbox: https://www.dropbox.com/s/b4sqi7dzzmp52xy/HandmadeHero.zip?dl=0
Cesar Peixoto
7 posts
Using VS instead of a Text Editor
Thank you very much!For some reason I did not have success.
I extracted the contents of the zip file. Open the project in VS and add existing item with the files received by preorder: handmade.cpp and handmade.h in handmadeDLL project. win32_handmade.cpp and win32_handmade.h in handmadeWin32 project.

When I try to build I get this error:

1>------ Build started: Project: HandmadeDLL, Configuration: Debug Win32 ------
1> handmade.cpp
1>d:\handemadehero\handmadehero\handmade.cpp(106): fatal error C1010: unexpected end of file while looking for precompiled header. Did you forget to add '#include "stdafx.h"' to your source?
2>------ Build started: Project: HandmadeWin32, Configuration: Debug Win32 ------
2> win32_handmade.cpp
2>d:\handemadehero\handmadehero\handmade.cpp(87): warning C4244: '+=' : conversion from 'real32' to 'int', possible loss of data
2> HandmadeWin32.vcxproj -> D:\HandeMadeHero\HandmadeHero\Debug\HandmadeWin32.exe
========== Build: 1 succeeded, 1 failed, 0 up-to-date, 0 skipped ==========

I'm sorry for the stupid question, but I need to do some other configuration to build solution in VS?
Thank you for your patience and attention
Kirill Basin
6 posts
Using VS instead of a Text Editor
Edited by Kirill Basin on
You have to select x64 configuration, it's the one we need for correct setup. According to logs you have Win32 right now.

If that won't fix it, for C1010 error look here on how to disable using precompiled headers: https://msdn.microsoft.com/en-us/library/d7fz9ckx.aspx. Second one is just a warning you can ignore for now, Casey will probably fix conversion in one of the following days.
Cesar Peixoto
7 posts
Using VS instead of a Text Editor
Edited by Cesar Peixoto on
Thanks again.

I believe I know where is the problem, however, can not think of a solution! How can make the file handmade.h see the contents of the file win32_handmade.cpp ???


I apologize again, is that I'm really lost here.
Cesar Peixoto
7 posts
Using VS instead of a Text Editor
Thanks again.

I believe I know where is the problem, however, can not think of a solution! How can make the file handmade.h see the contents of the file win32_handmade.cpp ???



I moved all the old content of the project to a temporary folder, I unzipped your file direct in the root, copied the files preorder (day 15) to folder. Open the project folder and removed the non-existent files. Changed for x64 and did build

========== Build: 0 succeeded, 2 failed, 0 up-to-date, 0 skipped ==========

UPDATED:

I realized that in handmade.h file it does not recognize #define internal, uint32, uint64, etc and Unable to find *.pdb file...
Realizing this, I moved all #define from win32_handmade.cpp to handmade.h. Build again and ...

1>
Build started: Project: HandmadeDLL, Configuration: Debug x64
1> Unable to find D:\HandmadeHero\x64\Debug\*.pdb
1> handmade.cpp
1>d:\handmadehero\handmade.cpp(48): error C2220: warning treated as error - no 'object' file generated
1>d:\handmadehero\handmade.cpp(105): error C2129: static function 'void DEBUGPlatformFreeFileMemory(void *)' declared but not defined
1> d:\handmadehero\handmade.h(82) : see declaration of 'DEBUGPlatformFreeFileMemory'
2>
Build started: Project: HandmadeWin32, Configuration: Debug x64
2> win32_handmade.cpp
2>d:\handmadehero\handmade.cpp(48): error C2220: warning treated as error - no 'object' file generated
========== Build: 0 succeeded, 2 failed, 0 up-to-date, 0 skipped ==========

UPDATE:

I disabled /WX to compile, Build again and:


1>
Build started: Project: HandmadeDLL, Configuration: Debug x64
1> Unable to find D:\HandmadeHero\x64\Debug\*.pdb
1> handmade.cpp
1>d:\handmadehero\handmade.cpp(105): error C2129: static function 'void DEBUGPlatformFreeFileMemory(void *)' declared but not defined
1> d:\handmadehero\handmade.h(82) : see declaration of 'DEBUGPlatformFreeFileMemory'

2>
Build started: Project: HandmadeWin32, Configuration: Debug x64
2> HandmadeWin32.vcxproj -> D:\HandmadeHero\x64\Debug\HandmadeWin32.exe
========== Build: 1 succeeded, 1 failed, 0 up-to-date, 0 skipped ==========


I believe I know where is the problem, however, can not think of a solution! How can I make the file handmade.h see the contents of the file win32_handmade.cpp ???

I apologize again, is that I'm really lost here.
Kirill Basin
6 posts
Using VS instead of a Text Editor
Edited by Kirill Basin on
At this point our setup was not 100% compatible with Casey code. You can see in his day 15 build.bat he compiles only win32_handmade.cpp which includes all the other files.

But in Visual Studio we have two projects and each of them compiles their own file: handmade.cpp and win32_handmade.cpp. At some point Casey will come to this and begin compiling them separately as well. For now we need to move some things around as you did.

As for the error you get now, it's simple: some of Casey's functions were declared static, i.e. they were only visible to other functions in the same file. Casey compiles only one file but we compile them separately thus creating a problem. So just remove "internal" keyword from functions declarations which give you this error in handmade.h.