- Avoid 'int' and associates. - 9 Updates
- Function pointer syntax - 2 Updates
- When auto can and can not deduce const - 2 Updates
Mr Flibble <flibbleREMOVETHISBIT@i42.co.uk>: Jun 13 08:24PM +0100 On 13/06/2015 20:18, Luca Risolia wrote: > Then what you are saying does not make any sense. > Why should the language provide a way to write: > auto i = 42s32; The language already does provide a way in the form of UDLs. I am proposing that the following UDLs be added to the C++ Standard Library: s8, s16, s32, s64, u8, u16, u32, u64. > if you can already safely initialize i with: > std::int32_t i{42}; > The compiler will produce a diagnostic on narrowing conversions. Yes the current situation of relying on compiler diagnostics or worse relying on unsafe non-portable code is so much better. </sarcasm> /Flibble |
woodbrian77@gmail.com: Jun 13 12:56PM -0700 On Saturday, June 13, 2015 at 1:05:37 PM UTC-5, Mr Flibble wrote: > means that code runs *correctly* as-is on all platforms for which it > compiles. > /Flibble I want my software to compile and run on as many platforms as possible. If you see any portability problems here, please let me know. I've tested it on PC-BSD, Linux and Windows and not found any problems. #include "platforms.hh" #include "ErrorWords.hh" #include "getaddrinfo_wrapper.hh" #include "poll_wrapper.hh" #include "ReceiveBufferStack.hh" #include "SendBufferStack.hh" #include <stdio.h> #include <stdlib.h> // exit #include "syslog_wrapper.hh" #include "zz.front_messages_middle.hh" using namespace ::cmw; int main (int argc,char** argv) { try{ if(argc<3 || argc>5) throw failure("Usage: direct account-number .req-file-path [node] [port]"); windows_start(); getaddrinfo_wrapper res(3==argc?"::1"/*"127.0.0.1"*/:argv[3] ,argc<5?"55555":argv[4],SOCK_DGRAM); auto rp=res.get(); SendBufferStack<> sendbuf; for(;rp!=nullptr;rp=rp->ai_next){ if((sendbuf.sock_=::socket(rp->ai_family,rp->ai_socktype,0))>0)break; } if(-1==sendbuf.sock_)throw failure("socket call(s) failed ")<<GetError(); ::pollfd pfd{sendbuf.sock_,POLLIN,0}; int waitMillisecs=30000; for(int j=0;j<2;++j,waitMillisecs*=2){ front_messages_middle::Marshal(sendbuf,marshalling_integer(argv[1]) ,argv[2]); sendbuf.Flush(rp->ai_addr,rp->ai_addrlen); if(poll_wrapper(&pfd,1,waitMillisecs)>0){ ReceiveBufferStack<SameFormat> buf(pfd.fd); if(!buf.GiveBool())throw failure("CMWA: ")<<buf.GiveCharStar(); ::exit(EXIT_SUCCESS); } } throw failure("No reply received. Is the middle tier (CMWA) running?"); }catch(::std::exception const& ex){ ::printf("%s: %s\n",argv[0],ex.what()); #ifndef CMW_WINDOWS ::openlog(argv[0],LOG_NDELAY,LOG_USER);
Subscribe to:
Post Comments (Atom)
|
No comments:
Post a Comment