I just want to lock() - is that so wrong?

Discussion in 'C++' started by Zerex71, Mar 25, 2008.

  1. Zerex71

    Zerex71 Guest

    Greetings group,

    I am stumped by the following situation: I completed a phase in coding
    my design in C# and all was smooth as silk, until I began the
    conversion to C++ for an embedded non-M$ platform (RHEL box). The
    problem I am running into is the following: I just want to convert the
    C# lock(this) statement into C++ but no matter what I do, the compiler
    balks. I am using MS VS2005. Here's the long and short of it:

    #include <msclr\lock.h>

    using namespace msclr; // Also set /clr compile option in the project
    properties

    // Inside my class' .cpp

    void MyClass::flush()
    {
    // Method serves to do one thing and one thing only - clear both
    queues
    lock(this); // *** offending LOC
    while (!incomingQueue.empty()) incomingQueue.pop();
    while (!outgoingQueue.empty())) outgoingQueue.pop();
    }

    I get a complaint by the compiler that msclr::lock does not have a
    copy constructor (like I care, right?). I just want to do the
    conversion and be on with life. It's been about 3 years since I've
    done C++ and looking at some of the converted code (I used a free tool
    online to get me going), it put a whole bunch of other looks-legit-but-
    I-have-no-idea-or-even-care stuff in my files. I don't think this
    should be a difficult task. Perhaps I'm forgetting something because
    lock (defined in lock.h) is a template class, but I just want to shut
    the compiler up and move on with life.

    Thanks in advance for any help you can provide.

    Mike
     
    Zerex71, Mar 25, 2008
    #1
    1. Advertisements

  2. Zerex71

    Christopher Guest

    On Mar 25, 3:21 pm, Zerex71 <> wrote:
    > Greetings group,
    >
    > I am stumped by the following situation: I completed a phase in coding
    > my design in C# and all was smooth as silk, until I began the
    > conversion to C++ for an embedded non-M$ platform (RHEL box). The
    > problem I am running into is the following: I just want to convert the
    > C# lock(this) statement into C++ but no matter what I do, the compiler
    > balks. I am using MS VS2005. Here's the long and short of it:
    >
    > #include <msclr\lock.h>
    >
    > using namespace msclr; // Also set /clr compile option in the project
    > properties
    >
    > // Inside my class' .cpp
    >
    > void MyClass::flush()
    > {
    > // Method serves to do one thing and one thing only - clear both
    > queues
    > lock(this); // *** offending LOC
    > while (!incomingQueue.empty()) incomingQueue.pop();
    > while (!outgoingQueue.empty())) outgoingQueue.pop();
    >
    > }
    >
    > I get a complaint by the compiler that msclr::lock does not have a
    > copy constructor (like I care, right?). I just want to do the
    > conversion and be on with life. It's been about 3 years since I've
    > done C++ and looking at some of the converted code (I used a free tool
    > online to get me going), it put a whole bunch of other looks-legit-but-
    > I-have-no-idea-or-even-care stuff in my files. I don't think this
    > should be a difficult task. Perhaps I'm forgetting something because
    > lock (defined in lock.h) is a template class, but I just want to shut
    > the compiler up and move on with life.
    >
    > Thanks in advance for any help you can provide.
    >
    > Mike


    Looks to me that you require the documentation for msclr/lock.h and
    the type you are using that comes from there. I'll make an educated
    guess and say that's some port of types from C# to Linux using C++.
    However, that type is no part of the C++ language itself, but rather
    part of some third party library. The thing to do then is read the
    documentation for the library you are using, ask on NGs or forums
    dedicated to that library. It is off-topic here.
     
    Christopher, Mar 25, 2008
    #2
    1. Advertisements

  3. Zerex71

    Christopher Guest

    On Mar 25, 3:51 pm, Christopher <> wrote:
    > On Mar 25, 3:21 pm, Zerex71 <> wrote:
    >
    >
    >
    > > Greetings group,

    >
    > > I am stumped by the following situation: I completed a phase in coding
    > > my design in C# and all was smooth as silk, until I began the
    > > conversion to C++ for an embedded non-M$ platform (RHEL box). The
    > > problem I am running into is the following: I just want to convert the
    > > C# lock(this) statement into C++ but no matter what I do, the compiler
    > > balks. I am using MS VS2005. Here's the long and short of it:

    >
    > > #include <msclr\lock.h>

    >
    > > using namespace msclr; // Also set /clr compile option in the project
    > > properties

    >
    > > // Inside my class' .cpp

    >
    > > void MyClass::flush()
    > > {
    > > // Method serves to do one thing and one thing only - clear both
    > > queues
    > > lock(this); // *** offending LOC
    > > while (!incomingQueue.empty()) incomingQueue.pop();
    > > while (!outgoingQueue.empty())) outgoingQueue.pop();

    >
    > > }

    >
    > > I get a complaint by the compiler that msclr::lock does not have a
    > > copy constructor (like I care, right?). I just want to do the
    > > conversion and be on with life. It's been about 3 years since I've
    > > done C++ and looking at some of the converted code (I used a free tool
    > > online to get me going), it put a whole bunch of other looks-legit-but-
    > > I-have-no-idea-or-even-care stuff in my files. I don't think this
    > > should be a difficult task. Perhaps I'm forgetting something because
    > > lock (defined in lock.h) is a template class, but I just want to shut
    > > the compiler up and move on with life.

    >
    > > Thanks in advance for any help you can provide.

    >
    > > Mike

    >
    > Looks to me that you require the documentation for msclr/lock.h and
    > the type you are using that comes from there. I'll make an educated
    > guess and say that's some port of types from C# to Linux using C++.
    > However, that type is no part of the C++ language itself, but rather
    > part of some third party library. The thing to do then is read the
    > documentation for the library you are using, ask on NGs or forums
    > dedicated to that library. It is off-topic here.


    P.S
    If you don't like that answer. Multithreading libraries are (right
    now) specific to your OS, except maybe boost if it has anything. You
    could always use the multithreading mechanism native to your platform.
    In which case, I'd Google pthreads for Linux.
     
    Christopher, Mar 25, 2008
    #3
  4. Zerex71

    Zerex71 Guest

    On Mar 25, 4:51 pm, Christopher <> wrote:
    > On Mar 25, 3:21 pm, Zerex71 <> wrote:
    >
    >
    >
    > > Greetings group,

    >
    > > I am stumped by the following situation: I completed a phase in coding
    > > my design in C# and all was smooth as silk, until I began the
    > > conversion to C++ for an embedded non-M$ platform (RHEL box). The
    > > problem I am running into is the following: I just want to convert the
    > > C# lock(this) statement into C++ but no matter what I do, the compiler
    > > balks. I am using MS VS2005. Here's the long and short of it:

    >
    > > #include <msclr\lock.h>

    >
    > > using namespace msclr; // Also set /clr compile option in the project
    > > properties

    >
    > > // Inside my class' .cpp

    >
    > > void MyClass::flush()
    > > {
    > > // Method serves to do one thing and one thing only - clear both
    > > queues
    > > lock(this); // *** offending LOC
    > > while (!incomingQueue.empty()) incomingQueue.pop();
    > > while (!outgoingQueue.empty())) outgoingQueue.pop();

    >
    > > }

    >
    > > I get a complaint by the compiler that msclr::lock does not have a
    > > copy constructor (like I care, right?). I just want to do the
    > > conversion and be on with life. It's been about 3 years since I've
    > > done C++ and looking at some of the converted code (I used a free tool
    > > online to get me going), it put a whole bunch of other looks-legit-but-
    > > I-have-no-idea-or-even-care stuff in my files. I don't think this
    > > should be a difficult task. Perhaps I'm forgetting something because
    > > lock (defined in lock.h) is a template class, but I just want to shut
    > > the compiler up and move on with life.

    >
    > > Thanks in advance for any help you can provide.

    >
    > > Mike

    >
    > Looks to me that you require the documentation for msclr/lock.h and
    > the type you are using that comes from there. I'll make an educated
    > guess and say that's some port of types from C# to Linux using C++.
    > However, that type is no part of the C++ language itself, but rather
    > part of some third party library. The thing to do then is read the
    > documentation for the library you are using, ask on NGs or forums
    > dedicated to that library. It is off-topic here.


    It's hardly off-topic to ask a C++-related question on a C++ newsgroup.
     
    Zerex71, Mar 25, 2008
    #4
  5. Zerex71

    Zerex71 Guest

    On Mar 25, 4:54 pm, Christopher <> wrote:
    > On Mar 25, 3:51 pm, Christopher <> wrote:
    >
    >
    >
    > > On Mar 25, 3:21 pm, Zerex71 <> wrote:

    >
    > > > Greetings group,

    >
    > > > I am stumped by the following situation: I completed a phase in coding
    > > > my design in C# and all was smooth as silk, until I began the
    > > > conversion to C++ for an embedded non-M$ platform (RHEL box). The
    > > > problem I am running into is the following: I just want to convert the
    > > > C# lock(this) statement into C++ but no matter what I do, the compiler
    > > > balks. I am using MS VS2005. Here's the long and short of it:

    >
    > > > #include <msclr\lock.h>

    >
    > > > using namespace msclr; // Also set /clr compile option in the project
    > > > properties

    >
    > > > // Inside my class' .cpp

    >
    > > > void MyClass::flush()
    > > > {
    > > > // Method serves to do one thing and one thing only - clear both
    > > > queues
    > > > lock(this); // *** offending LOC
    > > > while (!incomingQueue.empty()) incomingQueue.pop();
    > > > while (!outgoingQueue.empty())) outgoingQueue.pop();

    >
    > > > }

    >
    > > > I get a complaint by the compiler that msclr::lock does not have a
    > > > copy constructor (like I care, right?). I just want to do the
    > > > conversion and be on with life. It's been about 3 years since I've
    > > > done C++ and looking at some of the converted code (I used a free tool
    > > > online to get me going), it put a whole bunch of other looks-legit-but-
    > > > I-have-no-idea-or-even-care stuff in my files. I don't think this
    > > > should be a difficult task. Perhaps I'm forgetting something because
    > > > lock (defined in lock.h) is a template class, but I just want to shut
    > > > the compiler up and move on with life.

    >
    > > > Thanks in advance for any help you can provide.

    >
    > > > Mike

    >
    > > Looks to me that you require the documentation for msclr/lock.h and
    > > the type you are using that comes from there. I'll make an educated
    > > guess and say that's some port of types from C# to Linux using C++.
    > > However, that type is no part of the C++ language itself, but rather
    > > part of some third party library. The thing to do then is read the
    > > documentation for the library you are using, ask on NGs or forums
    > > dedicated to that library. It is off-topic here.

    >
    > P.S
    > If you don't like that answer. Multithreading libraries are (right
    > now) specific to your OS, except maybe boost if it has anything. You
    > could always use the multithreading mechanism native to your platform.
    > In which case, I'd Google pthreads for Linux.


    I should clarify and say that I have not ported the C# to the box yet,
    because I am doing the C++ conversion on my MS box at the moment.
    Once that compiles, I'll deal with the lib differences between MSXP
    and RHEL.

    Mike
     
    Zerex71, Mar 25, 2008
    #5
  6. Zerex71

    Christopher Guest

    On Mar 25, 4:08 pm, Zerex71 <> wrote:
    > On Mar 25, 4:51 pm, Christopher <> wrote:
    >
    >
    >
    > > On Mar 25, 3:21 pm, Zerex71 <> wrote:

    >
    > > > Greetings group,

    >
    > > > I am stumped by the following situation: I completed a phase in coding
    > > > my design in C# and all was smooth as silk, until I began the
    > > > conversion to C++ for an embedded non-M$ platform (RHEL box). The
    > > > problem I am running into is the following: I just want to convert the
    > > > C# lock(this) statement into C++ but no matter what I do, the compiler
    > > > balks. I am using MS VS2005. Here's the long and short of it:

    >
    > > > #include <msclr\lock.h>

    >
    > > > using namespace msclr; // Also set /clr compile option in the project
    > > > properties

    >
    > > > // Inside my class' .cpp

    >
    > > > void MyClass::flush()
    > > > {
    > > > // Method serves to do one thing and one thing only - clear both
    > > > queues
    > > > lock(this); // *** offending LOC
    > > > while (!incomingQueue.empty()) incomingQueue.pop();
    > > > while (!outgoingQueue.empty())) outgoingQueue.pop();

    >
    > > > }

    >
    > > > I get a complaint by the compiler that msclr::lock does not have a
    > > > copy constructor (like I care, right?). I just want to do the
    > > > conversion and be on with life. It's been about 3 years since I've
    > > > done C++ and looking at some of the converted code (I used a free tool
    > > > online to get me going), it put a whole bunch of other looks-legit-but-
    > > > I-have-no-idea-or-even-care stuff in my files. I don't think this
    > > > should be a difficult task. Perhaps I'm forgetting something because
    > > > lock (defined in lock.h) is a template class, but I just want to shut
    > > > the compiler up and move on with life.

    >
    > > > Thanks in advance for any help you can provide.

    >
    > > > Mike

    >
    > > Looks to me that you require the documentation for msclr/lock.h and
    > > the type you are using that comes from there. I'll make an educated
    > > guess and say that's some port of types from C# to Linux using C++.
    > > However, that type is no part of the C++ language itself, but rather
    > > part of some third party library. The thing to do then is read the
    > > documentation for the library you are using, ask on NGs or forums
    > > dedicated to that library. It is off-topic here.

    >
    > It's hardly off-topic to ask a C++-related question on a C++ newsgroup.


    According to who? You?
    Read the FAQ: Google "parashift C++ faq lite"

    This NG is not for everything "C++ related" it is for the C++ language
    itself.

    I cannot come here and expect people to start a discussion about
    "RainbowBriteAndFriends.lib" that I happened to find on a website
    somewhere. You can, however ask about _standard_ C++ libraries and
    their use.
     
    Christopher, Mar 25, 2008
    #6
  7. Zerex71

    Guest

    On Mar 25, 1:51 pm, Christopher <> wrote:
    > On Mar 25, 3:21 pm, Zerex71 <> wrote:

    [...]
    > > void MyClass::flush()
    > > {
    > > // Method serves to do one thing and one thing only - clear both
    > > queues
    > > lock(this); // *** offending LOC
    > > while (!incomingQueue.empty()) incomingQueue.pop();
    > > while (!outgoingQueue.empty())) outgoingQueue.pop();

    >
    > > }

    >
    > > I get a complaint by the compiler that msclr::lock does not have a
    > > copy constructor

    [...]
    > It is off-topic here.


    You are focusing on extra information given, which may be off-topic;
    but the OP is asking why the compiler thinks a copy constructor is
    needed there.

    Ali
     
    , Mar 25, 2008
    #7
  8. Zerex71

    Christopher Guest


    > You are focusing on extra information given, which may be off-topic;
    > but the OP is asking why the compiler thinks a copy constructor is
    > needed there.
    >
    > Ali


    And who knows without seeing the definition of lock which is defined
    in the third party library.

    There is no telling what lock is. Is it even a class? It could be a
    function... who knows. Hell, maybe its a macro. I think its obvious he
    is calling something that doesn't exist, but no one can tell him what
    does exist, except those that are familiar with his third party
    library.
     
    Christopher, Mar 25, 2008
    #8
  9. Zerex71

    Martin York Guest

    On Mar 25, 1:21 pm, Zerex71 <> wrote:
    > Greetings group,
    >
    > I am stumped by the following situation: I completed a phase in coding
    > my design in C# and all was smooth as silk, until I began the
    > conversion to C++ for an embedded non-M$ platform (RHEL box). The
    > problem I am running into is the following: I just want to convert the
    > C# lock(this) statement into C++ but no matter what I do, the compiler
    > balks. I am using MS VS2005. Here's the long and short of it:
    >
    > #include <msclr\lock.h>
    >
    > using namespace msclr; // Also set /clr compile option in the project
    > properties
    >
    > // Inside my class' .cpp
    >
    > void MyClass::flush()
    > {
    > // Method serves to do one thing and one thing only - clear both
    > queues
    > lock(this); // *** offending LOC
    > while (!incomingQueue.empty()) incomingQueue.pop();
    > while (!outgoingQueue.empty())) outgoingQueue.pop();
    >
    > }
    >
    > I get a complaint by the compiler that msclr::lock does not have a
    > copy constructor (like I care, right?). I just want to do the
    > conversion and be on with life. It's been about 3 years since I've
    > done C++ and looking at some of the converted code (I used a free tool
    > online to get me going), it put a whole bunch of other looks-legit-but-
    > I-have-no-idea-or-even-care stuff in my files. I don't think this
    > should be a difficult task. Perhaps I'm forgetting something because
    > lock (defined in lock.h) is a template class, but I just want to shut
    > the compiler up and move on with life.
    >
    > Thanks in advance for any help you can provide.
    >
    > Mike


    Try:
    lock myObjectLocker(this); // *** offending LOC
     
    Martin York, Mar 25, 2008
    #9
  10. Zerex71

    Zerex71 Guest

    On Mar 25, 7:55 pm, Martin York <> wrote:
    > On Mar 25, 1:21 pm, Zerex71 <> wrote:
    >
    >
    >
    > > Greetings group,

    >
    > > I am stumped by the following situation: I completed a phase in coding
    > > my design in C# and all was smooth as silk, until I began the
    > > conversion to C++ for an embedded non-M$ platform (RHEL box). The
    > > problem I am running into is the following: I just want to convert the
    > > C# lock(this) statement into C++ but no matter what I do, the compiler
    > > balks. I am using MS VS2005. Here's the long and short of it:

    >
    > > #include <msclr\lock.h>

    >
    > > using namespace msclr; // Also set /clr compile option in the project
    > > properties

    >
    > > // Inside my class' .cpp

    >
    > > void MyClass::flush()
    > > {
    > > // Method serves to do one thing and one thing only - clear both
    > > queues
    > > lock(this); // *** offending LOC
    > > while (!incomingQueue.empty()) incomingQueue.pop();
    > > while (!outgoingQueue.empty())) outgoingQueue.pop();

    >
    > > }

    >
    > > I get a complaint by the compiler that msclr::lock does not have a
    > > copy constructor (like I care, right?). I just want to do the
    > > conversion and be on with life. It's been about 3 years since I've
    > > done C++ and looking at some of the converted code (I used a free tool
    > > online to get me going), it put a whole bunch of other looks-legit-but-
    > > I-have-no-idea-or-even-care stuff in my files. I don't think this
    > > should be a difficult task. Perhaps I'm forgetting something because
    > > lock (defined in lock.h) is a template class, but I just want to shut
    > > the compiler up and move on with life.

    >
    > > Thanks in advance for any help you can provide.

    >
    > > Mike

    >
    > Try:
    > lock myObjectLocker(this); // *** offending LOC


    You know, I tried that, and it didn't work for me. That is similar to
    both of the LOCs I have seen in the MSDN and other online examples,
    and it still didn't work. I've even tried "lock myLock = new
    lock(this)" or lock l<MyClass> or things or that nature. None of it
    works. This lock.h, which is part of the MS CLR (as evidenced by the
    namespace) is not something some Joe Blow cooked up - it's part of the
    native VS2005 package. I don't know where else to turn.

    And, while we're on the topic of what's on topic, tell me again why a
    poster wouldn't want to post a C++-related thread on a newsgroup that
    is called "comp.lang.c++".

    Mike
     
    Zerex71, Mar 26, 2008
    #10
  11. Zerex71

    Guest

    On Mar 26, 9:09 am, Zerex71 <> wrote:

    > You know, I tried that, and it didn't work for me.  That is similar to
    > both of the LOCs I have seen in the MSDN and other online examples,
    > and it still didn't work.  I've even tried "lock myLock = new
    > lock(this)" or lock l<MyClass> or things or that nature.  None of it
    > works.  This lock.h, which is part of the MS CLR


    Right, which is why it's off-topic here. Ask in a MS newsgroup.
     
    , Mar 26, 2008
    #11
  12. Zerex71

    Guest

    On Mar 26, 9:09 am, Zerex71 <> wrote:

    > And, while we're on the topic of what's on topic, tell me again why a
    > poster wouldn't want to post a C++-related thread on a newsgroup that
    > is called "comp.lang.c++".


    http://tinylink.com/?3Eu8AMkJpR

    "First of all, please keep in mind that comp.lang.c++ is a group for
    discussion
    of general issues of the C++ programming language, as defined by the
    ANSI/ISO
    language standard. If you have a problem that is specific to a
    particular system
    or compiler, you are much more likely to get complete and accurate
    answers in a
    group that specializes in your platform. A listing of some newsgroups
    is given
    at the end of this post.
    "
     
    , Mar 26, 2008
    #12
  13. Zerex71

    Zerex71 Guest

    On Mar 26, 10:31 am, wrote:
    > On Mar 26, 9:09 am, Zerex71 <> wrote:
    >
    > > And, while we're on the topic of what's on topic, tell me again why a
    > > poster wouldn't want to post a C++-related thread on a newsgroup that
    > > is called "comp.lang.c++".

    >
    > http://tinylink.com/?3Eu8AMkJpR
    >
    > "First of all, please keep in mind that comp.lang.c++ is a group for
    > discussion
    > of general issues of the C++ programming language, as defined by the
    > ANSI/ISO
    > language standard. If you have a problem that is specific to a
    > particular system
    > or compiler, you are much more likely to get complete and accurate
    > answers in a
    > group that specializes in your platform. A listing of some newsgroups
    > is given
    > at the end of this post.
    > "


    Still sounds C++-related to me. Next?
     
    Zerex71, Mar 26, 2008
    #13
  14. Zerex71

    Zerex71 Guest

    On Mar 26, 10:28 am, wrote:
    > On Mar 26, 9:09 am, Zerex71 <> wrote:
    >
    > > You know, I tried that, and it didn't work for me. That is similar to
    > > both of the LOCs I have seen in the MSDN and other online examples,
    > > and it still didn't work. I've even tried "lock myLock = new
    > > lock(this)" or lock l<MyClass> or things or that nature. None of it
    > > works. This lock.h, which is part of the MS CLR

    >
    > Right, which is why it's off-topic here. Ask in a MS newsgroup.


    I didn't know we were so tribal about what we could talk about here.
    You'd think the C++ experts would jump at the chance to help with
    questions of this nature.
     
    Zerex71, Mar 26, 2008
    #14
  15. Zerex71

    Guest

    On Mar 26, 9:38 am, Zerex71 <> wrote:
    > On Mar 26, 10:31 am, wrote:
    >
    >
    >
    >
    >
    > > On Mar 26, 9:09 am, Zerex71 <> wrote:

    >
    > > > And, while we're on the topic of what's on topic, tell me again why a
    > > > poster wouldn't want to post a C++-related thread on a newsgroup that
    > > > is called "comp.lang.c++".

    >
    > >http://tinylink.com/?3Eu8AMkJpR

    >
    > > "First of all, please keep in mind that comp.lang.c++ is a group for
    > > discussion
    > > of general issues of the C++ programming language, as defined by the
    > > ANSI/ISO
    > > language standard. If you have a problem that is specific to a
    > > particular system
    > > or compiler, you are much more likely to get complete and accurate
    > > answers in a
    > > group that specializes in your platform. A listing of some newsgroups
    > > is given
    > > at the end of this post.
    > > "

    >
    > Still sounds C++-related to me.  Next?


    The CLR's lock mechanism is in the C++ ISO standard?
     
    , Mar 26, 2008
    #15
  16. Zerex71

    Guest

    On Mar 26, 10:39 am, Zerex71 <> wrote:
    > On Mar 26, 10:28 am, wrote:
    >
    > > On Mar 26, 9:09 am, Zerex71 <> wrote:

    >
    > > > You know, I tried that, and it didn't work for me. That is similar to
    > > > both of the LOCs I have seen in the MSDN and other online examples,
    > > > and it still didn't work. I've even tried "lock myLock = new
    > > > lock(this)" or lock l<MyClass> or things or that nature. None of it
    > > > works. This lock.h, which is part of the MS CLR

    >
    > > Right, which is why it's off-topic here. Ask in a MS newsgroup.

    >
    > I didn't know we were so tribal about what we could talk about here.


    There is no tribality here (well not in this thread, at least ;-).
    It's just that, IIUC, your question is about porting from C# to C++/
    CLI, which is a different language than C++.
     
    , Mar 26, 2008
    #16
  17. Zerex71

    Guest

    On Mar 26, 9:39 am, Zerex71 <> wrote:
    > On Mar 26, 10:28 am, wrote:
    >
    > > On Mar 26, 9:09 am, Zerex71 <> wrote:

    >
    > > > You know, I tried that, and it didn't work for me.  That is similar to
    > > > both of the LOCs I have seen in the MSDN and other online examples,
    > > > and it still didn't work.  I've even tried "lock myLock = new
    > > > lock(this)" or lock l<MyClass> or things or that nature.  None of it
    > > > works.  This lock.h, which is part of the MS CLR

    >
    > > Right, which is why it's off-topic here.  Ask in a MS newsgroup.

    >
    > I didn't know we were so tribal about what we could talk about here.
    > You'd think the C++ experts would jump at the chance to help with
    > questions of this nature.


    Chances are if anyone here knew the CLR, they might offer help, along
    with a gentle nudge to the right newsgroup.

    It's not that we're tribal, it's that we don't want the newsgroup
    flooded with platform-specific questions when newsgroups dedicated to
    those platforms exist. Pointing you in their direction is meant to
    be help, not serve as a personal attack.

    I could ask OpenGL questions here, but why would I when
    comp.graphics.api.opengl exists?
     
    , Mar 26, 2008
    #17
  18. Zerex71

    peter koch Guest

    On 25 Mar., 21:21, Zerex71 <> wrote:
    > Greetings group,
    >
    > I am stumped by the following situation: I completed a phase in coding
    > my design in C# and all was smooth as silk, until I began the
    > conversion to C++ for an embedded non-M$ platform (RHEL box).  The
    > problem I am running into is the following: I just want to convert the
    > C# lock(this) statement into C++ but no matter what I do, the compiler
    > balks.  I am using MS VS2005.  Here's the long and short of it:
    >
    > #include <msclr\lock.h>
    >
    > using namespace msclr;  // Also set /clr compile option in the project


    This is not a standard namespace.

    > properties
    >
    > // Inside my class' .cpp
    >
    > void MyClass::flush()
    > {
    >     // Method serves to do one thing and one thing only - clear both
    > queues
    >     lock(this); // *** offending LOC


    And lock is not a standard function...

    [snip]

    My guess is that you are compiling for C++/CLR. That name is quite
    unfortunate, because it is not C++. I do not know if I qualify as a C+
    + expert, but I do believe that I know the language very well, but we
    are in no position to help you here. Microsoft has lots of groups and
    lots of knowledgeable experts participate in that group (many of them
    I believe, are from Microsoft). So ask your question there - it serves
    you much better (and far better than your questioning the topicality
    of your posts).

    /Peter
     
    peter koch, Mar 26, 2008
    #18
  19. In message
    <>,
    Zerex71 <> writes
    >On Mar 26, 10:31 am, wrote:
    >> On Mar 26, 9:09 am, Zerex71 <> wrote:
    >>
    >> > And, while we're on the topic of what's on topic, tell me again why a
    >> > poster wouldn't want to post a C++-related thread on a newsgroup that
    >> > is called "comp.lang.c++".

    >>
    >> http://tinylink.com/?3Eu8AMkJpR
    >>
    >> "First of all, please keep in mind that comp.lang.c++ is a group for
    >> discussion
    >> of general issues of the C++ programming language, as defined by the
    >> ANSI/ISO
    >> language standard. If you have a problem that is specific to a
    >> particular system
    >> or compiler, you are much more likely to get complete and accurate
    >> answers in a
    >> group that specializes in your platform. A listing of some newsgroups
    >> is given
    >> at the end of this post.
    >> "

    >
    >Still sounds C++-related to me.


    From the hint "// Also set /clr compile option in the project
    properties" it sounds C++/CLI related to me. Despite the misleadingly
    similar name, that's an entirely different language.

    >Next?


    Keep digging, and all the knowledgeable posters here will surely push
    you into the resulting pit, or their killfiles.

    Did you read this part of the FAQ?

    "Include the smallest, complete and compilable program that exhibits
    your
    problem."

    That would as a minimum have included the definition of your "lock"
    class or function, or whatever it is, since it is not a part of the C++
    standard and nobody here can read minds.

    --
    Richard Herring
     
    Richard Herring, Mar 26, 2008
    #19
  20. Zerex71

    Zerex71 Guest

    On Mar 26, 10:53 am, ""
    <> wrote:
    > On Mar 26, 10:39 am, Zerex71 <> wrote:
    >
    > > On Mar 26, 10:28 am, wrote:

    >
    > > > On Mar 26, 9:09 am, Zerex71 <> wrote:

    >
    > > > > You know, I tried that, and it didn't work for me. That is similar to
    > > > > both of the LOCs I have seen in the MSDN and other online examples,
    > > > > and it still didn't work. I've even tried "lock myLock = new
    > > > > lock(this)" or lock l<MyClass> or things or that nature. None of it
    > > > > works. This lock.h, which is part of the MS CLR

    >
    > > > Right, which is why it's off-topic here. Ask in a MS newsgroup.

    >
    > > I didn't know we were so tribal about what we could talk about here.

    >
    > There is no tribality here (well not in this thread, at least ;-).
    > It's just that, IIUC, your question is about porting from C# to C++/
    > CLI, which is a different language than C++.


    I was asking because locking things, mutexing, etc. and so forth seems
    a pretty standard C++ feature, even if by "standard" it is part of
    some thing like the STL. My hope was that someone here had the answer
    rather than jumping on me for the semantic equivalent of jaywalking.
    I had hoped someone who had done this in C++ had the answer. More
    effort has been expending on trying to get me to report than to
    actually producing the answer (Lord knows how nerds hate when you put
    something in the wrong box).

    To me, there is nothing *that* off-topic about asking about this
    question. Sure, there is the CLR keyword that jumps out, but lock is
    part of C++, at least Microsoft's interpretation of it. Perhaps a
    renaming of the newsgroup should be in order? I saw plenty of things
    posted to this group that had the stamp of "programming question" on
    it. If someone here doesn't like the content, then make the group
    moderated.

    If I had a truly Windows-specific question, then I would have went
    looking there (i.e MFC, forms, .NET, UI, MSDN, etc.) but this seems
    pretty generic. Oh well. On to bigger and better things.

    Mike
     
    Zerex71, Mar 26, 2008
    #20
    1. Advertisements

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments (here). After that, you can post your question and our members will help you out.
Similar Threads
  1. Fuzzyman
    Replies:
    3
    Views:
    830
    Andrew MacIntyre
    Dec 5, 2003
  2. Êé´ôÅí
    Replies:
    7
    Views:
    699
    James Kanze
    Oct 19, 2008
  3. k3xji
    Replies:
    7
    Views:
    1,220
    Gabriel Genellina
    Dec 30, 2008
  4. nano2k

    Application.Lock()/UnLock() or lock(Application)

    nano2k, Jul 23, 2007, in forum: ASP .Net Web Services
    Replies:
    2
    Views:
    653
    nano2k
    Aug 9, 2007
  5. PerlFAQ Server

    FAQ 5.22 Why can't I just open(FH, ">file.lock")?

    PerlFAQ Server, Feb 4, 2011, in forum: Perl Misc
    Replies:
    0
    Views:
    248
    PerlFAQ Server
    Feb 4, 2011
  6. Moh

    I need a VHDL code

    Moh, Jun 8, 2016, in forum: VHDL
    Replies:
    0
    Views:
    720
  7. ivan gagula

    RTL to VHDL

    ivan gagula, Jun 22, 2016, in forum: Introductions
    Replies:
    0
    Views:
    645
    ivan gagula
    Jun 22, 2016
  8. alxcam8
    Replies:
    0
    Views:
    703
    alxcam8
    Jun 29, 2016
Loading...