<?xml version='1.0' encoding='UTF-8'?><?xml-stylesheet href="http://www.blogger.com/styles/atom.css" type="text/css"?><feed xmlns='http://www.w3.org/2005/Atom' xmlns:openSearch='http://a9.com/-/spec/opensearchrss/1.0/' xmlns:georss='http://www.georss.org/georss' xmlns:gd='http://schemas.google.com/g/2005' xmlns:thr='http://purl.org/syndication/thread/1.0'><id>tag:blogger.com,1999:blog-3002256527193598864</id><updated>2011-04-21T17:47:44.640-04:00</updated><title type='text'>Notes on Software Development</title><subtitle type='html'></subtitle><link rel='http://schemas.google.com/g/2005#feed' type='application/atom+xml' href='http://fraxedas.blogspot.com/feeds/posts/default'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/3002256527193598864/posts/default?max-results=100'/><link rel='alternate' type='text/html' href='http://fraxedas.blogspot.com/'/><link rel='hub' href='http://pubsubhubbub.appspot.com/'/><author><name>fraxedas</name><uri>http://www.blogger.com/profile/07169053496258474731</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><generator version='7.00' uri='http://www.blogger.com'>Blogger</generator><openSearch:totalResults>2</openSearch:totalResults><openSearch:startIndex>1</openSearch:startIndex><openSearch:itemsPerPage>100</openSearch:itemsPerPage><entry><id>tag:blogger.com,1999:blog-3002256527193598864.post-193762360884894879</id><published>2009-02-26T09:43:00.002-05:00</published><updated>2009-02-26T10:04:47.478-05:00</updated><title type='text'>Very useful ansi-c macros</title><content type='html'>These are some macro definitions that can be useful for the c programmer.&lt;br /&gt;My biggest headache on c has always been the error display: &lt;em&gt;sigsegv&lt;/em&gt; segmentation &lt;em&gt;fault.&lt;/em&gt;&lt;br /&gt;&lt;br /&gt;/*&lt;br /&gt; * Definitions&lt;br /&gt; */&lt;br /&gt;#define TRUE         1&lt;br /&gt;#define FALSE         0&lt;br /&gt;#define OK            0&lt;br /&gt;#define ERROR         1&lt;br /&gt;&lt;br /&gt;/**&lt;br /&gt; * Return the minimum value&lt;br /&gt; */&lt;br /&gt;#define min(a,b) ((a)&lt;(b)?a:b)&lt;br /&gt;&lt;br /&gt;/**&lt;br /&gt; * Return the maximum value&lt;br /&gt; */&lt;br /&gt;#define max(a,b) ((a)&gt;(b)?a:b)&lt;br /&gt;&lt;br /&gt;/**&lt;br /&gt; * Template to allocate memory with error display before terminating&lt;br /&gt; */&lt;br /&gt;#define malloc2(Result,DataType,Count,FunctionName,VariableName)    \&lt;br /&gt;    if(!(Result=(DataType *)malloc(sizeof(DataType)*(Count)))){\&lt;br /&gt;        printf("%s: memory error allocating %s\n",FunctionName,VariableName);\&lt;br /&gt;        exit(1);\&lt;br /&gt;    }&lt;br /&gt;&lt;br /&gt;/**&lt;br /&gt; * Template to allocate memory and set to 0 with error display before terminating&lt;br /&gt; */&lt;br /&gt;#define calloc2(Result,DataType,Count,FunctionName,VariableName)    \&lt;br /&gt;    if(!(Result=(DataType *)calloc((Count),sizeof(DataType)))){\&lt;br /&gt;        printf("%s: memory error allocating %s\n",FunctionName,VariableName);\&lt;br /&gt;        exit(1);\&lt;br /&gt;    }&lt;br /&gt;&lt;br /&gt;/**&lt;br /&gt; * Template to reallocate memory with error display before terminating&lt;br /&gt; */&lt;br /&gt;#define realloc2(Result,DataType,Count,FunctionName,VariableName)    \&lt;br /&gt;    if(!(Result=(DataType *)realloc(Result,sizeof(DataType)*(Count)))){\&lt;br /&gt;        printf("%s: memory error reallocating %s\n",FunctionName,VariableName);\&lt;br /&gt;        exit(1);\&lt;br /&gt;    }&lt;br /&gt;&lt;br /&gt;/**&lt;br /&gt; * Template to free the allocated memory&lt;br /&gt; */&lt;br /&gt;#define free2(This)    \&lt;br /&gt;        if(This){\&lt;br /&gt;            free(This);\&lt;br /&gt;            (This)=NULL;\&lt;br /&gt;        }\&lt;br /&gt;&lt;br /&gt;/**&lt;br /&gt; * Template to open a file for Reading, with error display before terminating&lt;br /&gt; */&lt;br /&gt;#define fopen2r(File,Path,FunctionName)    \&lt;br /&gt;    if(!(File=fopen(Path,"r"))){\&lt;br /&gt;        printf("%s: error while opening %s for reading\n",FunctionName,Path);\&lt;br /&gt;        exit(1);\&lt;br /&gt;    }&lt;br /&gt;&lt;br /&gt;/**&lt;br /&gt; * Template to open a file for Writing, with error display before terminating&lt;br /&gt; */&lt;br /&gt;#define fopen2w(File,Path,FunctionName)    \&lt;br /&gt;    if(!(File=fopen(Path,"w"))){\&lt;br /&gt;        printf("%s: error while opening %s for writing\n",FunctionName,Path);\&lt;br /&gt;        exit(1);\&lt;br /&gt;    }&lt;br /&gt;&lt;br /&gt;/**&lt;br /&gt; * Template to open a file for Writing, with error display before terminating&lt;br /&gt; */&lt;br /&gt;#define fopen2a(File,Path,FunctionName)    \&lt;br /&gt;    if(!(File=fopen(Path,"a"))){\&lt;br /&gt;        printf("%s: error while opening %s for appending\n",FunctionName,Path);\&lt;br /&gt;        exit(1);\&lt;br /&gt;    }&lt;br /&gt;&lt;br /&gt;/**&lt;br /&gt; * Template to open a file for Writing, with error display before terminating&lt;br /&gt; */&lt;br /&gt;#define fopen2custom(File,Path,Argument,FunctionName)    \&lt;br /&gt;    if(!(File=fopen(Path,Argument))){\&lt;br /&gt;        printf("%s: error while opening %s with the argument %s\n",FunctionName,Path,Argument);\&lt;br /&gt;        exit(1);\&lt;br /&gt;    }&lt;br /&gt;&lt;br /&gt;Sample:&lt;br /&gt;&lt;br /&gt;The malloc2 macro is use as:&lt;br /&gt;&lt;br /&gt;&lt;span style="font-style: italic;"&gt;int *this;&lt;/span&gt;&lt;br /&gt;&lt;span style="font-style: italic;"&gt;&lt;/span&gt;&lt;span style="color: rgb(51, 51, 255); font-weight: bold; font-style: italic;"&gt;malloc2&lt;/span&gt;&lt;span style="font-style: italic;"&gt;(this,int,30,"Chronometer_New","this");&lt;/span&gt;&lt;br /&gt; &lt;span style="font-style: italic;"&gt;&lt;/span&gt;&lt;br /&gt;Instead of the malloc fuction:&lt;br /&gt;&lt;br /&gt;&lt;span style="font-style: italic;"&gt;int *this=(int *)&lt;/span&gt;&lt;span style="font-weight: bold; color: rgb(51, 51, 255); font-style: italic;"&gt;malloc&lt;/span&gt;&lt;span style="font-style: italic;"&gt;(sizeof(int)*(30)));&lt;/span&gt;&lt;br /&gt; &lt;br /&gt;and a nice error display will be shown if something fail, showing the function name and the variable name.&lt;br /&gt;&lt;br /&gt;I hope this can be helpful for someone.&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/3002256527193598864-193762360884894879?l=fraxedas.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://fraxedas.blogspot.com/feeds/193762360884894879/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://fraxedas.blogspot.com/2009/02/very-useful-ansi-c-macros.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/3002256527193598864/posts/default/193762360884894879'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/3002256527193598864/posts/default/193762360884894879'/><link rel='alternate' type='text/html' href='http://fraxedas.blogspot.com/2009/02/very-useful-ansi-c-macros.html' title='Very useful ansi-c macros'/><author><name>fraxedas</name><uri>http://www.blogger.com/profile/07169053496258474731</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-3002256527193598864.post-6433466906015598345</id><published>2009-02-26T09:14:00.005-05:00</published><updated>2009-03-27T14:33:44.142-04:00</updated><title type='text'>Howto add a dll app.config file in setup project in Visual Studio</title><content type='html'>Steps to ship the config file with the dll in a setup project.&lt;br /&gt;&lt;span style="font-style: italic;"&gt;In my particular case I needed the dll config file for a WCF service client inside a MMC snapin.&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;For the library:&lt;br /&gt;&lt;ol&gt;&lt;li&gt;Create a dll project. (e.g. myLibrary)&lt;br /&gt;&lt;/li&gt;&lt;li&gt;Add a configuration file.&lt;/li&gt;&lt;li&gt;Rename the configuration file as "projectName".dll.config. (e.g. myLibrary.config.dll)&lt;br /&gt;&lt;/li&gt;&lt;li&gt;View the properties for the configuration file and set them to: &lt;/li&gt;&lt;/ol&gt;&lt;ul&gt;&lt;li&gt;Build action: Content (to reference later in setup)&lt;br /&gt;&lt;/li&gt;&lt;li&gt;Copy to output: Copy always&lt;/li&gt;&lt;/ul&gt;For the deployment project:&lt;br /&gt;&lt;ol&gt;&lt;li&gt;Create a setup project or a merge module.&lt;/li&gt;&lt;li&gt;Select the Add the project  output and then:&lt;/li&gt;&lt;/ol&gt;&lt;ul&gt;&lt;li&gt;Select primary output for the library project. (this includes the dll)&lt;/li&gt;&lt;li&gt;Select project content for the library. (this includes the configuration file)&lt;/li&gt;&lt;/ul&gt;Simple and painless :-)&lt;br /&gt;Hope can help someone with this.&lt;br /&gt;Works for C# or VB.NET.&lt;br /&gt;&lt;span style="font-style: italic;"&gt;&lt;/span&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/3002256527193598864-6433466906015598345?l=fraxedas.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://fraxedas.blogspot.com/feeds/6433466906015598345/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://fraxedas.blogspot.com/2009/02/howto-add-dll-appconfig-file-in-setup.html#comment-form' title='1 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/3002256527193598864/posts/default/6433466906015598345'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/3002256527193598864/posts/default/6433466906015598345'/><link rel='alternate' type='text/html' href='http://fraxedas.blogspot.com/2009/02/howto-add-dll-appconfig-file-in-setup.html' title='Howto add a dll app.config file in setup project in Visual Studio'/><author><name>fraxedas</name><uri>http://www.blogger.com/profile/07169053496258474731</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>1</thr:total></entry></feed>
