Archived

This topic is now archived and is closed to further replies.

Useful

MSVC++ 6 scripts?

Recommended Posts

Useful    122
Is there a way to configure Visual C++ to say: automaticly make the correct declarations needed for static variables? like:
  
class Foo
{
  static float bar = 5.0f;
};
   
Ive been using java for a bit and I wish the compiler would just assume that it should write this
  
class Foo
{
  static float bar;
};

float Foo::bar = 5.0f;
   
Is there any way to program stuff like this in? I'd love something to either write the structure i need for my .cpp file when i define things in the header. I'd also love if it would move code from my header into the source file. There are tons of small little automated tasks that really irk me after having to use java... cant it look through the headers in the include files and see that if im using std::string it automaticly add #include <string> ? [edited by - useful on June 7, 2002 9:32:17 PM]

Share this post


Link to post
Share on other sites
Guest Anonymous Poster   
Guest Anonymous Poster
yeah the whole header/source thing is really a bother to me. The IDE should handle it all for us. It isn''t as if we are programming directly in C++ anyway, the numerous #includes aren''t C++, they''re cpp. So why not just have directive to split it for us? As it is I write it all in the header, then I copy it to the cpp, then I delete the code from the header replacing with semicolons and then I go fix the cpp.

Share this post


Link to post
Share on other sites
WizHarDx    190
C++ does loads of helpful stuff, about moving everything from class to sourcefile it does.

Goto class view, right click on it & choose create Generic Class & name it whatever u want.

It then creates header file + source file with class implmented in source file & protoyped in header file.

Share this post


Link to post
Share on other sites
Useful    122
Im aware that I can create a generic class and I use the function, but it doesnt help me at all past that. Once I'm done creating the interface for a class, I have to go into the source and rewrite(basiclly) all the same stuff into source.

    
// header.h

#ifndef __FOO_H__ // generated by msvc++

#define __FOO_H__ // generated by msvc++
class Foo {
public:
void bar();
};
#endif



// source.cpp

#include "header.h" // generated by msvc++

void Foo::bar() {} // why cant this also be generated



[edited by - useful on June 8, 2002 7:12:26 AM]

Share this post


Link to post
Share on other sites
henrym    103
Has anybody else noticed how stupid this thread is?
Stop being so lazy...there isn''t any way for this to work(ATM anyway) and you''re going to have to fill in the implementation of that method anyway so all its going to save you typing is about 30 characters(+ or - depending on the args, class name, etc.)

Just do it normally.

Henrym

Share this post


Link to post
Share on other sites
IndirectX    122
quote:
Original post by henrym
Has anybody else noticed how stupid this thread is?


Yeah.

This is not VB for you. Your programming style isn''t the only one in existence. In many cases, for instance, you want to keep function code in headers.

Read your post again. Think how you would implement any of the "features" you proposed. The answer is, you can''t. If you want to code with your mouse instead of the keyboard, go use VB.

Share this post


Link to post
Share on other sites
Dean Harding    546
quote:
Original post by Useful
Im aware that I can create a generic class and I use the function, but it doesnt help me at all past that. Once I'm done creating the interface for a class, I have to go into the source and rewrite(basiclly) all the same stuff into source.



Well, once you do that, go to the class view, right click on the class and go "Add Function", or "Add Variable", or something like that...


codeka.com - Just click it.

[edited by - Dean Harding on June 8, 2002 7:52:22 PM]

Share this post


Link to post
Share on other sites
Kylotan    9972
You could write a Developer Studio macro

The redundancy is partly to ensure backwards compatibility with C and partly because it makes for quicker compile times. An IDE could do it for you, in theory, providing you don''t mind it making arbitrary decisions about where you want it to be initialised.

Lastly, you should be able to initialise it in the header if it''s static const. Some compilers don''t allow this though. In some cases, you may be able to use an enum instead for the same effect.

[ MSVC Fixes | STL | SDL | Game AI | Sockets | C++ Faq Lite | Boost | Asking Questions | Organising code files ]

Share this post


Link to post
Share on other sites
Useful    122
I only provided this as sort of an example of what I wanted. Another example would be code autoformatting. Having an option that recognized that you were lazy and didnt tab your variables/defines to align each other.

We have templates for our programs, why cant we have code templates? Things like these are enforced in the work world when you code to make things more readable to others. MS Word does simple stuff like this when your write a document.

I''d love to make something like this for visual studio, now I have to ask how? If I can''t, I''ll have to do it with TextPad or some other IDE, or write my own IDE(which doesnt seem a good choice).

Share this post


Link to post
Share on other sites
Guest Anonymous Poster   
Guest Anonymous Poster
quote:
Original post by Useful
Having an option that recognized that you were lazy and didnt tab your variables/defines to align each other.


How about an option that recognized that you were lazy and locked you out from the compiler until you actually wanted to put some effort into what you were doing?

Or maybe you''d like an option that made your game for you?

Or surely at least one that took away such tedious tasks as dividing your code into functions, or making sure your variables were the right type?

Share this post


Link to post
Share on other sites
Useful    122
quote:
Original post by Anonymous Poster
How about an option that recognized that you were lazy and locked you out from the compiler until you actually wanted to put some effort into what you were doing?

Or maybe you'd like an option that made your game for you?

Or surely at least one that took away such tedious tasks as dividing your code into functions, or making sure your variables were the right type?


And I bet you put all your format your code by hitting tab a few times after every line. Im talking about extending the autoformating, thats no different than the ide automaticly indenting my code.

[edited by - useful on June 9, 2002 12:59:07 PM]

Share this post


Link to post
Share on other sites
T2k    220
quote:

class Foo{static float bar;};
float Foo::bar = 5.0f;

Is there any way to program stuff like this in?



nop, why should vc++ produce bugs ? never tried constructors ?


T2k

[edited by - T2k on June 10, 2002 9:12:00 AM]

Share this post


Link to post
Share on other sites