Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
X

Xpnctoc

@Xpnctoc
About
Posts
163
Topics
52
Shares
0
Groups
0
Followers
0
Following
0

Posts

Recent Best Controversial

  • To Link or Not To Link? (Question of Efficiency)
    X Xpnctoc

    That's kind of what I thought. Does having a larger executable result in slower app launch time? When exactly to statically linked DLLs get loaded -- on application start, first call, etc...?

    Design and Architecture help question json lounge

  • To Link or Not To Link? (Question of Efficiency)
    X Xpnctoc

    I thought about using function pointers. But then the sheer number of them I would need to generate and maintain at application start-up seems like it would be more work that it's worth. Might as well just stick with static linking or a static library.

    Design and Architecture help question json lounge

  • To Link or Not To Link? (Question of Efficiency)
    X Xpnctoc

    Well I guess I could have been a little clearer, but since, as you said, .NET and Java always do dynamic loads, that's obviously not what I'm talking about. I'm talking about plain old C++. I also did specifically mention video games and real-time simulations.

    Design and Architecture help question json lounge

  • To Link or Not To Link? (Question of Efficiency)
    X Xpnctoc

    General architectural question: From what I've been able to gather, there are basically 3 approaches to handling code that is reusable across multiple projects: 1. Dynamic linking: build a DLL, use API functions like LoadLibrary() and GetProcAddress() to link to the desired functionality at run time. 2. Static linking: build a DLL, use a .lib file to establish the external proc addresses at compile time. 3. Static library: build a LIB only, use as input that becomes part of the .exe file for a given project. It seems pretty obvious that #1 would represent the worst execution time because of the need to look up a proc address before calling it. But the issue seems a little more fuzzy between #2 and #3. Is there a significant advantage to one over the other in general? What about in high-demand applications such as video games or real-time simulators, or where the library function is expected to be called dozens of times per second? Thanks for your help.

    Design and Architecture help question json lounge

  • Function pointer syntax help
    X Xpnctoc

    That's OK by me. I don't recall ever using defaults... not since college 15 years ago anyway when some homework assignment was specifically targeted at it. I do a fair amount of work in C# too, which doesn't allow defaults, so I'm used to it.

    ATL / WTL / STL help question

  • Function pointer syntax help
    X Xpnctoc

    Oh, there it is. I don't know how I missed that before :-)

    ATL / WTL / STL help question

  • Function pointer syntax help
    X Xpnctoc

    Yeah, I figured that out. Do you happen to know what (if any) standard they do conform to? I know there are several through the years.

    ATL / WTL / STL help question

  • Function pointer syntax help
    X Xpnctoc

    Thanks for the tip.

    ATL / WTL / STL help question

  • Function pointer syntax help
    X Xpnctoc

    I found the problem. I only posted a limited version of the code to focus the direction of the inquiry. In the context of the full code, what is going on is that the compiler expects all variables to be declared at the beginning of the function. Original code:

    #include typedef void (*VoidFunctionPtr)(void);

    void FunctionA(void)
    {
    printf("You are in Function A.\n");
    }

    int main(void)
    {
    printf("Here is a program that does something.\n");
    VoidFunctionPtr fp = FunctionA; // FAILS because variables must be declared first.
    fp();
    }

    Revised code:

    #include typedef void (*VoidFunctionPtr)(void);

    void FunctionA(void)
    {
    printf("You are in Function A.\n");
    }

    int main(void)
    {
    VoidFunctionPtr fp = FunctionA; // MOVED variable declaration to first line.

    printf("Here is a program that does something.\\n");
    fp();
    

    }

    I'm sure this wouldn't happen in a C++ project, but I am using compiler settings to force Standard C compilation. I come from a C++ background but I'm trying to learn the differences between C++ and standard C. I bought a book on standard C, but it references the "C99" standard, which apparently allows variables to be defined anywhere in a function. I guess the MS C compiler works on an older standard?

    ATL / WTL / STL help question

  • Function pointer syntax help
    X Xpnctoc

    I am using VS2010 Premium. I come from a C++ background but I need to learn what the difference is between that and standard C. To facilitate that goal I created an empty C++ project and then set the following Project Properties to disable C++ components: Language -> Disable Language Extensions = YES (command line switch /Za) Advanced -> Compile As = Compile As C Code (command line switch /TC)

    ATL / WTL / STL help question

  • Function pointer syntax help
    X Xpnctoc

    Can someone tell me what's wrong with this code:

    #include typedef void (*VoidFunctionPtr)(void);

    void FunctionA()
    {
    printf("You are in Function A.\n");
    }

    void FunctionB()
    {
    printf("You are in Function B.\n");
    }

    int main(void)
    {
    VoidFunctionPtr fp = FunctionA;
    fp();
    }

    In main(), the declaration of variable "fp" throws a C2275 error: "'VoidFunctionPtr': illegal use of this type as an expression." I don't get it. I have cross-referenced several books and internet articles. All show the same syntax. What am I missing?

    ATL / WTL / STL help question

  • ANSI C in VS 2010
    X Xpnctoc

    Thanks.

    ATL / WTL / STL c++ question visual-studio com

  • ANSI C in VS 2010
    X Xpnctoc

    Well this is a tangent, but I totally disagree. The project was created by using the "Empty Project" template under the C++ templates list in the new project dialog... That implies the user intends to make a C++ project, and so at least those settings could be applied as a starting point. I mean, if I am browsing the C++ templates it's not because I intend to create a VB project or something. At least give me the minimum C++ settings as a starting point.

    ATL / WTL / STL c++ question visual-studio com

  • ANSI C in VS 2010
    X Xpnctoc

    Never mind. I found the issue. Apparently the C/C++ property page doesn't show up until you have added at least one source code file. I was trying to configure it before adding any source code files. Seems kind of lame, but there we have it. I am leaving this post up to hopefully help someone else who might run into the same problem.

    ATL / WTL / STL c++ question visual-studio com

  • ANSI C in VS 2010
    X Xpnctoc

    First, I know this question isn't exactly ATL/WTL/STL. I see no category at all in CodeProject.com that really fits this question, so this is as close as I could get. I'm trying to configure a project to accept only ANSI-C syntax. I have read articles that say this can be accomplished by using the /TC and /Za switches. However, I don't see where in the project properties to set them. From MSDN: 1. Open the project's Property Pages dialog box. For details, see How to: Open Project Property Pages. 2. Click the C/C++ folder. 3. Click the Advanced property page. 4. Modify the Compile As property. PROBLEM: When I open the Project Property pages, there is *NO* "C/C++ folder". Can anyone on this forum be more helpful than MS's own documentation? Thank you.

    ATL / WTL / STL c++ question visual-studio com

  • What is meant by "STL Relational Database" programming?
    X Xpnctoc

    That sounds really intriguing and I'd love to read it, but $80 (Amazon Marketplace) for a mere 150 pages is terribly steep.

    ATL / WTL / STL database question csharp c++ mysql

  • What is meant by "STL Relational Database" programming?
    X Xpnctoc

    Hello all. I've recently been digging around the job market and several times I've come across programmer positions that are asking for candidates with experience in "STL relational database" development. I'm wondering what exactly is meant by that? In my exposure to STL in general I don't recall coming across anything akin to .NET classes such as DataTable, DataRow, DataSet, etc... So when an employer makes this request, what are they looking for? I can think of two possibilities: 1. Just looking for someone who knows how to establish ODBC connections with STL to retrieve data from a data source (SQL Server, MySQL, Oracle, or whatever) and populate simple STL data structures like Lists. 2. Use simple STL structures to actually program an entire database-like series of interrelated classes so that no database is even needed on the back end. Can anyone clarify this for me? Also, can anyone point me to a good, *in-depth* STL resource (websites or published books)? Thanks for reading!

    ATL / WTL / STL database question csharp c++ mysql

  • Some thoughts about virtual methods [modified]
    X Xpnctoc

    I agree with Luc on performance issues, but I disagree when he say that the added structure would not be beneficial. If your core Job function cannot stand on its own (i.e., requires pre- and post- function, regardless of how different those functions may be from derived class to derived class), then I personally would absolutely declare the Pre- and Post- as "abstract" methods to ensure that every new derived class you create implements Pre- and Post-. This is exactly why "abstract" declarations were invented. You could then invoke Pre- and Post- from Base::Job and not have to implement a Derived::Job method at all. Like this (I apologize if my syntax isn't perfect. Been doing a lot of C++/CLI, so I might not be completely right in native C++ syntax):

    class Base
    {
    public:
    virtual void Job()
    {
    Pre();
    // actual job code here
    Post();
    }
    protected:
    virtual void Pre() abstract;
    virtual void Post() abstract;
    }

    class Derived : public Base
    {
    protected:
    virtual void Pre() override
    {
    //derived-specific pre-job code here
    }

    virtual void Post() override
    {
    //derived-specific post-job code here
    }
    }

    // Calling Code:
    Derived* myDerived = new Derived();
    myDerived->Job(); // invokes Job in base class, which in turn invokes Pre/Post in derived class.

    Design and Architecture c++ discussion csharp php asp-net

  • Possible inefficiency in post-increment FOR loop?
    X Xpnctoc

    I was reading a coding style document put out by a certain company, when I came across an odd claim in their justification for their FOR loop style. I was wondering if someone could shed some light on this for me: The document states that a pre-increment operator is preferable to a post-increment operator because post-increment introduces potential inefficiencies when iterating over an object. The example they give is C++ code:

    std::vector v;
    // vector gets filled here....
    for (std::vector::const_iterator i = v.begin(); i != v.end(); ++i)
    {
    // iteration code here...
    }

    ...and an identical sample that uses "i++" instead of "++i" for the increment operation. I see no difference in the efficiency. Whether using ++i or i++, "i" is going to contain its new value before the termination condition is evaluated. The loop will be iterated an identical number of times. I was wondering if someone could shed some light on what it is that I'm missing here, or if perhaps the assertion that pre-increment is more efficient. Is there some other language or platform that treats identical FOR loop sytax in a wildly different manner?

    Design and Architecture c++ graphics tutorial question

  • Basic string help -- Did I step into the Twilight Zone?
    X Xpnctoc

    Re-ordering the #includes did the trick. I had read about the use of printf/cout but I hadn't gotten to that point since I couldn't even get my variable declaration to compile. Thanks for the pointers.

    ATL / WTL / STL c++ help question
  • Login

  • Don't have an account? Register

  • Login or register to search.
  • First post
    Last post
0
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups