Advertisement Jump to content
  • Advertisement

DarkRadeon

Member
  • Content Count

    58
  • Joined

  • Last visited

Community Reputation

108 Neutral

About DarkRadeon

  • Rank
    Member
  1. thx u now everything is clear... I belived there was some strange behaviours with the pointer arithmetic... but the reality is more trivial than what I thought
  2. Here we are: http://msdn.microsof...y/3b2e7499.aspx When you use Visual C++ to create applications to run on a 64-bit Windows operating system, you should be aware of the following issues: An int and a long are 32-bit values on 64-bit Windows operating systems. For programs that you plan to compile for 64-bit platforms, you should be careful not to assign pointers to 32-bit variables. Pointers are 64-bit on 64-bit platforms, and you will truncate the pointer value if you assign it to a 32-bit variable. [/quote] OK, I know I'm not a genius... but is that sentence right? Here's a simple code to test that (sorry for the end ): #include <iostream> int main( ) { int i [ 4 ] = { 1, 2 ,3 ,4 }; long l [ 4 ] = { 11, 22 ,33 ,44 }; long long ll [ 44 ] = { 111, 222 ,333 ,444 }; void* p = NULL; p = &i; std::cout << "p = &i" << std::endl; std::cout << "p = " << p << std::endl; std::cout << "&p = " << &p << std::endl; for( int i = 0; i < 4; i++ ) { std::cout << "*( p + " << i << " ) = " << *( static_cast< int* >( p ) + i ) << std::endl; } std::cout << std::endl; p = &l; std::cout << "p = &l" << std::endl; std::cout << "p = " << p << std::endl; std::cout << "&p = " << &p << std::endl; for( int i = 0; i < 4; i++ ) { std::cout << "*( p + " << i << " ) = " << *( static_cast< long* >( p ) + i ) << std::endl; } std::cout << std::endl; p = &ll; std::cout << "p = &ll" << std::endl; std::cout << "p = " << p << std::endl; std::cout << "&p = " << &p << std::endl; for( int i = 0; i < 4; i++ ) { std::cout << "*( p + " << i << " ) = " << *( static_cast< long long* >( p ) + i ) << std::endl; } std::cout << std::endl; char ch = '\n'; std::cin >> ch; return( 0 ); } Here is the output: [attachment=7623:asd.PNG] Everything seems to works fine... so.. Where is the truncation?
  3. Yes, I know that, but the source files were not written by me, I tested only the "cost" of the algorithm the had... [/quote] Thank you for the link : D. The code was written for different linux machines (servers and a distribute net), so probably the author did not care about windows memory model... Now it's all clear : ) Thank you guys.
  4. mmm OK, now I understand that the stack reserve size is expressed in byte and not int MB... now with the correct value it works perfectly..
  5. I know that but the applications I tested never had big allocation memory (topically 10-100MB) In visual studio, on the linker option there are bot Stack and Heap reserve Size, both are set to 1MB as default. I also worked with some linux server, where I couldn't touch nothing except submitting source code, the server had the task to compile it and run it sending to me result like time execution time compilation etc.. The biggest single "object" I had in the various programs were arrays of on million integers, like int a[ 1000000 ] and on both windows and linux an int should be 4 bytes, so 4 millions bytes, ~3.8MB, not a big problem for machines equipped with at least 4GB RAM.. I'm actually abstain from C++, but I notice that making global or static those array solve that kind of problem... Maybe I should see again the C++ memory allocation model xD
  6. Were you not debugging? If you were, you would have received a "Stack Overflow" exception... [/quote] because I used different IDEs and compilers I was "testing" on many machines.. and only on Windows PCs I had that problem and I knew that the code was right, so I didn't think about debugging..
  7. Yes, I only learn it today, after an entire afternoon spent with several algorithms and data structures C++ samples getting crash on Windows for unknown reason -.- One answer could be: "for optimization kinda stuffs..." ... I mean, are you kidding me Microsoft? Why don't you give me a simple message like "Hey you dumb-ass, here you cannot allocate more then 1MiB onto stack or you must change the linker option"? On several linux machines all worked fine, even with very large stack allocations (more than 100MB), so what is the real reason? I know that generally having a really big stack is not so common (an a good idea), but why Microsoft set a lot of limitation without warning the user? ç___ç edit: wow, same limitation for the heap :|
  8. DarkRadeon

    Frank Luna - DirectX 9.0 A Shader Approach

    starting to vs 2010 you should manually link the dxsdk library to the linker in the project proprieties... or manually editing the MSbuild profile.. fortunately the next DXSDK should be a part of the next windows sdk, so this problem will solved..
  9. mmm OK, but this should avoid the need of VC++ redistributable for the end user.. I hope that with VC++12 MS will finally bring standard Unicode support (VC++11 will not support it .-. )
  10. DarkRadeon

    Not sure how to get into C++

    you can also download Bruce Eckels free electronic version of thinking in c++ 2nd edition, vol1 and vol2: http://www.mindviewinc.com/Books/downloads.html
  11. DarkRadeon

    Not sure how to get into C++

    C++ is no more an "extension" of C. It was... 20 yeas ago or when it comes out for the first time. Just because with C++ you can write some procedural code that a C compiler can read (with some few restrictions) it doesn't mean C++ is a superset of C language. Today they are two different languages. Personally I think that ISO should break C compatibility but this is just mine thought and another story...
  12. Tnx I will continue to use DeleteFileW of Windows.h..
  13. I must delete a file with an Unicode name. The file-name is stored in a wstring. Is there a way to do it without using windows api? std::remove( ) of cstdio library doesn't work with wchar_t...
  14. DarkRadeon

    Avoiding polymorphism in Java

    no, you cannot. You will brake LSP (Liskov substitution principle) do you know how using Polymorphism caused a problem in one of my programs when a constructor called the wrong function. I've settled the problem, but I would like to be able to avoid in the future. [/quote] post an example of that constructor issue... do you remember how constructors works with subclassing and the role of the "super" keyword?
  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

GameDev.net is your game development community. Create an account for your GameDev Portfolio and participate in the largest developer community in the games industry.

Sign me up!