Skip to content

Commit

Permalink
docs
Browse files Browse the repository at this point in the history
  • Loading branch information
thradams committed Feb 27, 2024
1 parent 4826a01 commit 5d4205f
Show file tree
Hide file tree
Showing 5 changed files with 124 additions and 66 deletions.
56 changes: 36 additions & 20 deletions manual.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,26 +11,6 @@ On Windows, Cake can be used on the command line in the same way as MSVC. Cake w

To discover what directories are included, you can run the command 'echo %INCLUDE%' at Visual Studio command prompt.

```
echo %INCLUDE%
```


Copy this output to `cakeconfig.h`.
For instance:

```
#pragma dir "C:/Program Files/Microsoft Visual Studio/2022/Preview/VC/Tools/MSVC/14.37.32820/include"
#pragma dir "C:/Program Files/Microsoft Visual Studio/2022/Preview/VC/Auxiliary/VS/include"
#pragma dir "C:/Program Files (x86)/Windows Kits/10/include/10.0.22000.0/ucrt"
#pragma dir "C:/Program Files (x86)/Windows Kits/10//include/10.0.22000.0/um"
#pragma dir "C:/Program Files (x86)/Windows Kits/10//include/10.0.22000.0/shared"
#pragma dir "C:/Program Files (x86)/Windows Kits/10//include/10.0.22000.0/winrt"
#pragma dir "C:/Program Files (x86)/Windows Kits/10//include/10.0.22000.0/cppwinrt"
```

When cake runs it first tries to load cakeconfig.h, that must exist at same dir of cake.exe.

On Linux, the same file `cakeconfig.h` is used. To find out what are the directories used by GCC type
Expand All @@ -39,6 +19,42 @@ On Linux, the same file `cakeconfig.h` is used. To find out what are the directo
echo | gcc -E -Wp,-v -
```

Sample of cakeconfig.h

```
#ifdef __linux__
/*
To find the include directories used my GCC type:
echo | gcc -E -Wp,-v -
*/
#pragma dir "/usr/lib/gcc/x86_64-linux-gnu/11/include"
#pragma dir "/usr/local/include"
#pragma dir "/usr/include/x86_64-linux-gnu"
#pragma dir "/usr/include"
#endif
#ifdef _WIN32
/*
To find the include directories used my MSVC,
open Visual Studio Developer Commmand prompt and type:
echo %INCLUDE%.
Running Cake inside mscv command prompt uses %INCLUDE% automatically.
*/
#pragma dir "C:/Program Files/Microsoft Visual Studio/2022/Professional/VC/Tools/MSVC/14.38.33130/include"
#pragma dir "C:/Program Files/Microsoft Visual Studio/2022/Professional/VC/Tools/MSVC/14.38.33130/ATLMFC/include"
#pragma dir "C:/Program Files/Microsoft Visual Studio/2022/Professional/VC/Auxiliary/VS/include"
#pragma dir "C:/Program Files (x86)/Windows Kits/10/include/10.0.22000.0/ucrt"
#pragma dir "C:/Program Files (x86)/Windows Kits/10/include/10.0.22000.0/um"
#pragma dir "C:/Program Files (x86)/Windows Kits/10/include/10.0.22000.0/shared"
#pragma dir "C:/Program Files (x86)/Windows Kits/10/include/10.0.22000.0/winrt"
#pragma dir "C:/Program Files (x86)/Windows Kits/10/include/10.0.22000.0/cppwinrt"
#pragma dir "C:/Program Files (x86)/Windows Kits/NETFXSDK/4.8/include/um"
#endif
```

Cake also includes standard header files. The objective is to allow usage even without installing GCC or MSVC. You can set this path on `cakeconfig.h` but mixing cake headers with other headers is not recommended.

Expand Down
31 changes: 26 additions & 5 deletions src/cakeconfig.h
Original file line number Diff line number Diff line change
@@ -1,10 +1,31 @@

#ifdef __linux__

//#pragma dir "/usr/lib/gcc/x86_64-linux-gnu/11/include"
//#pragma dir "/usr/local/include"
//#pragma dir "/usr/include/x86_64-linux-gnu"
//#pragma dir "/usr/include"
/*
To find the include directories used my GCC type:
echo | gcc -E -Wp,-v -
*/
#pragma dir "/usr/lib/gcc/x86_64-linux-gnu/11/include"
#pragma dir "/usr/local/include"
#pragma dir "/usr/include/x86_64-linux-gnu"
#pragma dir "/usr/include"

#endif

#ifdef _WIN32
/*
To find the include directories used my MSVC,
open Visual Studio Developer Commmand prompt and type:
echo %INCLUDE%.
Running Cake inside mscv command prompt uses %INCLUDE% automatically.
*/
#pragma dir "C:/Program Files/Microsoft Visual Studio/2022/Professional/VC/Tools/MSVC/14.38.33130/include"
#pragma dir "C:/Program Files/Microsoft Visual Studio/2022/Professional/VC/Tools/MSVC/14.38.33130/ATLMFC/include"
#pragma dir "C:/Program Files/Microsoft Visual Studio/2022/Professional/VC/Auxiliary/VS/include"
#pragma dir "C:/Program Files (x86)/Windows Kits/10/include/10.0.22000.0/ucrt"
#pragma dir "C:/Program Files (x86)/Windows Kits/10/include/10.0.22000.0/um"
#pragma dir "C:/Program Files (x86)/Windows Kits/10/include/10.0.22000.0/shared"
#pragma dir "C:/Program Files (x86)/Windows Kits/10/include/10.0.22000.0/winrt"
#pragma dir "C:/Program Files (x86)/Windows Kits/10/include/10.0.22000.0/cppwinrt"
#pragma dir "C:/Program Files (x86)/Windows Kits/NETFXSDK/4.8/include/um"

#endif
47 changes: 24 additions & 23 deletions src/lib.c
Original file line number Diff line number Diff line change
Expand Up @@ -5201,7 +5201,7 @@ struct token_list control_line(struct preprocessor_ctx* ctx, struct token_list*
while (input_list->head->type != TK_NEWLINE)
{
prematch_level(p_list, input_list, level);
}
}
}
match_token_level(p_list, input_list, TK_NEWLINE, level, ctx);

Expand Down Expand Up @@ -6830,13 +6830,14 @@ void add_standard_macros(struct preprocessor_ctx* ctx)
"#define __STDC_OWNERSHIP__\n"
"#define _W_DIVIZION_BY_ZERO_ 29\n"

#ifdef WIN32
#ifdef _WIN32

//see
//https://learn.microsoft.com/en-us/cpp/preprocessor/predefined-macros?view=msvc-170

#ifdef _WIN32
"#define _WIN32 " TOSTRING(_WIN32) "\n"

#ifdef _WINDOWS_
"#define _WINDOWS_ " TOSTRING(_WINDOWS_) "\n"
#endif

#ifdef _WIN64
Expand Down Expand Up @@ -33164,27 +33165,27 @@ static void flow_visit_expression(struct flow_visit_ctx* ctx, struct expression*
{
if (p_expression->right)
{
struct type t = { 0 };
struct object* p_object = expression_get_object(p_expression->right, &t);
struct type t = { 0 };
struct object* p_object = expression_get_object(p_expression->right, &t);

if (!ctx->expression_is_not_evaluated)
{
if (p_object && p_object->state == OBJECT_STATE_UNINITIALIZED)
{
compiler_diagnostic_message(W_ANALYZER_UNINITIALIZED,
ctx->ctx,
p_expression->right->first_token, "using a uninitialized object");
}
else if (p_object && p_object->state & OBJECT_STATE_UNINITIALIZED)
if (!ctx->expression_is_not_evaluated)
{
compiler_diagnostic_message(W_ANALYZER_UNINITIALIZED,
ctx->ctx,
p_expression->right->first_token, "maybe using a uninitialized object");
if (p_object && p_object->state == OBJECT_STATE_UNINITIALIZED)
{
compiler_diagnostic_message(W_ANALYZER_UNINITIALIZED,
ctx->ctx,
p_expression->right->first_token, "using a uninitialized object");
}
else if (p_object && p_object->state & OBJECT_STATE_UNINITIALIZED)
{
compiler_diagnostic_message(W_ANALYZER_UNINITIALIZED,
ctx->ctx,
p_expression->right->first_token, "maybe using a uninitialized object");
}
}
}
type_destroy(&t);
type_destroy(&t);



flow_visit_expression(ctx, p_expression->right);
}

Expand Down Expand Up @@ -34011,10 +34012,10 @@ static void flow_visit_declarator(struct flow_visit_ctx* ctx, struct declarator*
set_object(&t2, p_declarator->object.pointed, (OBJECT_STATE_NOT_NULL | OBJECT_STATE_NULL));
}
type_destroy(&t2);
}
#endif
}
#endif
}
}

/*if (p_declarator->pointer)
{
Expand Down
7 changes: 4 additions & 3 deletions src/tokenizer.c
Original file line number Diff line number Diff line change
Expand Up @@ -4511,13 +4511,14 @@ void add_standard_macros(struct preprocessor_ctx* ctx)
"#define __STDC_OWNERSHIP__\n"
"#define _W_DIVIZION_BY_ZERO_ 29\n"

#ifdef WIN32
#ifdef _WIN32

//see
//https://learn.microsoft.com/en-us/cpp/preprocessor/predefined-macros?view=msvc-170

#ifdef _WIN32
"#define _WIN32 " TOSTRING(_WIN32) "\n"

#ifdef _WINDOWS_
"#define _WINDOWS_ " TOSTRING(_WINDOWS_) "\n"
#endif

#ifdef _WIN64
Expand Down
49 changes: 34 additions & 15 deletions src/web/manual.html
Original file line number Diff line number Diff line change
Expand Up @@ -283,28 +283,47 @@ <h2 id="toc_1">Include directories</h2>

<p>To discover what directories are included, you can run the command &#39;echo %INCLUDE%&#39; at Visual Studio command prompt.</p>

<pre><code>echo %INCLUDE%
<p>When cake runs it first tries to load cakeconfig.h, that must exist at same dir of cake.exe. </p>

<p>On Linux, the same file <code>cakeconfig.h</code> is used. To find out what are the directories used by GCC type</p>

<pre><code>echo | gcc -E -Wp,-v -
</code></pre>

<p>Copy this output to <code>cakeconfig.h</code>.<br>
For instance:</p>
<p>Sample of cakeconfig.h</p>

<pre><code>
#pragma dir &quot;C:/Program Files/Microsoft Visual Studio/2022/Preview/VC/Tools/MSVC/14.37.32820/include&quot;
#pragma dir &quot;C:/Program Files/Microsoft Visual Studio/2022/Preview/VC/Auxiliary/VS/include&quot;
#pragma dir &quot;C:/Program Files (x86)/Windows Kits/10/include/10.0.22000.0/ucrt&quot;
#pragma dir &quot;C:/Program Files (x86)/Windows Kits/10//include/10.0.22000.0/um&quot;
#pragma dir &quot;C:/Program Files (x86)/Windows Kits/10//include/10.0.22000.0/shared&quot;
#pragma dir &quot;C:/Program Files (x86)/Windows Kits/10//include/10.0.22000.0/winrt&quot;
#pragma dir &quot;C:/Program Files (x86)/Windows Kits/10//include/10.0.22000.0/cppwinrt&quot;
<pre><code>
#ifdef __linux__
/*
To find the include directories used my GCC type:
echo | gcc -E -Wp,-v -
*/
#pragma dir &quot;/usr/lib/gcc/x86_64-linux-gnu/11/include&quot;
#pragma dir &quot;/usr/local/include&quot;
#pragma dir &quot;/usr/include/x86_64-linux-gnu&quot;
#pragma dir &quot;/usr/include&quot;

</code></pre>
#endif

<p>When cake runs it first tries to load cakeconfig.h, that must exist at same dir of cake.exe. </p>
#ifdef _WIN32
/*
To find the include directories used my MSVC,
open Visual Studio Developer Commmand prompt and type:
echo %INCLUDE%.
Running Cake inside mscv command prompt uses %INCLUDE% automatically.
*/
#pragma dir &quot;C:/Program Files/Microsoft Visual Studio/2022/Professional/VC/Tools/MSVC/14.38.33130/include&quot;
#pragma dir &quot;C:/Program Files/Microsoft Visual Studio/2022/Professional/VC/Tools/MSVC/14.38.33130/ATLMFC/include&quot;
#pragma dir &quot;C:/Program Files/Microsoft Visual Studio/2022/Professional/VC/Auxiliary/VS/include&quot;
#pragma dir &quot;C:/Program Files (x86)/Windows Kits/10/include/10.0.22000.0/ucrt&quot;
#pragma dir &quot;C:/Program Files (x86)/Windows Kits/10/include/10.0.22000.0/um&quot;
#pragma dir &quot;C:/Program Files (x86)/Windows Kits/10/include/10.0.22000.0/shared&quot;
#pragma dir &quot;C:/Program Files (x86)/Windows Kits/10/include/10.0.22000.0/winrt&quot;
#pragma dir &quot;C:/Program Files (x86)/Windows Kits/10/include/10.0.22000.0/cppwinrt&quot;
#pragma dir &quot;C:/Program Files (x86)/Windows Kits/NETFXSDK/4.8/include/um&quot;

<p>On Linux, the same file <code>cakeconfig.h</code> is used. To find out what are the directories used by GCC type</p>
#endif

<pre><code>echo | gcc -E -Wp,-v -
</code></pre>

<p>Cake also includes standard header files. The objective is to allow usage even without installing GCC or MSVC. You can set this path on <code>cakeconfig.h</code> but mixing cake headers with other headers is not recommended.</p>
Expand Down

0 comments on commit 5d4205f

Please sign in to comment.