小编Kos*_*mos的帖子

#include重复发现的任何工具?

这听起来很奇怪,但也许存在一个...我用Google搜索,但没有找到任何东西.
简单的例子:
我有一个文件class1.h:

#include "a.h"
#include "b.h"
Run Code Online (Sandbox Code Playgroud)

另一个文件class2.h:

#include "a.h"
#include "c.h"
Run Code Online (Sandbox Code Playgroud)

和main.cpp:

#include "class2.h" //as we see here, we getting "a.h" double included by class1.h and class2.h
Run Code Online (Sandbox Code Playgroud)

我想在我的项目中摆脱这种欺骗.

当然,在例子中并没有那么难,但我有大量的文件,它们在很多方面相互包含,很难自己追踪所有的欺骗.

在我自己编写该工具之前,有什么建议吗?:)

c++ include duplicates

3
推荐指数
1
解决办法
1986
查看次数

试图将字符串的第一个符号转换为int,得到奇怪的值

static void Main(string[] args)
{
    string str_val = "8584348,894";
    //int prefix = Convert.ToInt32(str_val[0]); //prefix = 56 O_o
    //int prefix = (int)str_val[0]; //what, again 56? i need 8!
    int prefix = Convert.ToInt32("8"); //at least this works -_-
}
Run Code Online (Sandbox Code Playgroud)

知道如何将第一个符号转换为正确的数值?

c# string integer

2
推荐指数
1
解决办法
1661
查看次数

如何在c#中将资源作为字节数组?

我从项目设置 - >资源
中将图像添加到我的c#项目中如何在运行时获取此图像?
我试着这个:

public byte[] GetResource(string ResourceName)
{
    System.Reflection.Assembly asm = Assembly.GetEntryAssembly();

    // list all resources in assembly - for test
    string[] names = asm.GetManifestResourceNames(); //even here my TestImg.png is not presented

    System.IO.Stream stream = asm.GetManifestResourceStream(ResourceName); //this return null of course

    byte[] data = new byte[stream.Length];

    stream.Read(data, 0, (int)stream.Length);

    return data;
}
Run Code Online (Sandbox Code Playgroud)

我这样称呼这个函数:

byte[] data = GetResource("TestImg.png");
Run Code Online (Sandbox Code Playgroud)

但我在项目浏览器的Resources文件夹中看到了我的图像.
在此输入图像描述

有谁能说出那里有什么问题?
在此输入图像描述

c# embedded-resource

2
推荐指数
1
解决办法
7425
查看次数

我使用CreateWindowExA来创建窗口.为什么我的窗口标题文本显示为多字节编码?

我有这个程序:

#include <Windows.h>

LRESULT CALLBACK WndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam)
{
    switch(message)
    {
        case WM_CLOSE:
            PostQuitMessage(0);
            break;

        default:
            return DefWindowProc(hWnd, message, wParam, lParam);
    }

    return 0;
}

int main()
{
    WNDCLASSA wnd_class = { 0 }; 
    wnd_class.lpfnWndProc = WndProc;
    wnd_class.hInstance = GetModuleHandle(NULL);
    wnd_class.lpszClassName = "actwnd";

    RegisterClassA(&wnd_class);

    HWND main_wnd = CreateWindowA(wnd_class.lpszClassName, "Program activation", WS_OVERLAPPEDWINDOW | WS_VISIBLE, 0, 0, 640, 480, NULL, 0, wnd_class.hInstance, NULL);

    MSG msg = { 0 };
    while(GetMessage(&msg, NULL, 0, 0) > 0)
    {
        TranslateMessage(&msg); …
Run Code Online (Sandbox Code Playgroud)

c++ windows winapi

2
推荐指数
1
解决办法
983
查看次数

如何使用 SQL 语句将查询结果插入到 Google BigQuery 中的现有表中?

我有一个巨大的_query_that_runs_fine_alone以 开头select

\n\n

我想将该查询结果插入到现有表中,但通常的 SQL 语句不起作用。

\n\n

我尝试过:插入 test_ds.test_tbl (field1, \xe2\x80\xa6, fieldN) 值(巨大_query_that_runs_fine_aloneselect ),但查询编辑器在意想不到的地方告诉我该关键字;

\n\n

这是: select * into test_ds.test_tbl from ( huge_query_that_runs_fine_alone ),但查询编辑器告诉我这个Syntax error: Unexpected keyword INTO at [1:10]

\n\n

该怎么办?

\n\n

PS 完整查询...

\n\n
insert into test_bq_dataset.test_tbl (Naimenovanie_SKU, Naimenovanie_TT, MonthNo, YearNo, AmountPromo, SumPromo, AmountNoPromo, SumNoPromo) values (select promos.Naimenovanie_SKU, promos.Naimenovanie_TT, promos.MonthNo, promos.YearNo, AmountPromo, SumPromo, AmountNoPromo, SumNoPromo from\n(select Naimenovanie_SKU, Naimenovanie_TT, MonthNo, YearNo, sum(Prodazhi_Litry) as AmountPromo, sum(Prodazhi_Summa_s_NDS) as SumPromo from IACloud0539_Calc.Data2_PROMO where Promo …
Run Code Online (Sandbox Code Playgroud)

google-bigquery

2
推荐指数
1
解决办法
1万
查看次数

微软边缘不支持嵌入标签?

我测试此代码适用于除Microsoft Edge之外的每个浏览器.

<html>
    <head>
        <title>test embed</title>
    </head>

    <body>
        <embed autoplay = 'false' type = 'video/mp4' src = 'http://download.wavetlan.com/SVV/Media/HTTP/H264/Talkinghead_Media/H264_test1_Talkinghead_mp4_480x360.mp4' />
    </body>
</html>
Run Code Online (Sandbox Code Playgroud)

但是,我无法找到有关此标签支持的任何信息.也许我们需要做一些其他embed工作才能在Edge工作?

Edge女士只显示空白页面.

我不打算用object.

html embed microsoft-edge

1
推荐指数
1
解决办法
4948
查看次数

触发器中 MySql 的 NEW.some_column 的 SQL Server 模拟是什么?

这是我第一次处理 SQL Server 触发器。

在此之前,我为 MySql Server 编写了几乎相同的触发器,现在尝试为 SQL Server 重新编码。我修复了所有东西,但现在不明白它想要什么?我们如何才能像在 MySQL 中那样访问刚刚插入的行的某些列 - NEW.some_field?

CREATE TRIGGER AntiCloneInsert ON dbo.user_item FOR INSERT AS

DECLARE @acc_id INT;
DECLARE @items_count INT;

IF (NEW.item_type in (select item_type from dbo.forbidden_item_types))
BEGIN
    select @items_count = count(item_type) from dbo.user_item where item_type = NEW.item_type and warehouse = NEW.warehouse
    IF (@items_count > 1)
    BEGIN
        select @acc_id = account_id from dbo.user_data where char_id = NEW.char_id
        update lin2db.dbo.user_account set block_flag2 = 1 where uid = @acc_id
    END
END
Run Code Online (Sandbox Code Playgroud)

我尝试创建此触发器但收到此类错误:

消息 …

mysql sql sql-server

1
推荐指数
1
解决办法
153
查看次数

来自特定索引的字节数组作为 C# 中的结构,而不进行复制

目前,我编写了客户端-服务器垃圾代码,并处理了大量通过网络传递的 C++ 结构。我知道这里提供的方法从字节数组中读取 C# 中的 C/C++ 数据结构,但它们都是关于制作副本的。

我想要这样的东西:

struct/*or class*/ SomeStruct
{
    public uint F1;
    public uint F2;
    public uint F3;
}
Run Code Online (Sandbox Code Playgroud)

稍后在我的代码中我想要类似的东西:

byte[] Data; //16 bytes that I got from network
SomeStruct PartOfDataAsSomeStruct { get { return /*make SomeStruct instance based on this.Data starting from index 4, without copying it. So when I do PartOfDataAsSomeStruct.F1 = 132465; it also changes bytes 4, 5, 6 and 7 in this.Data.*/; } }
Run Code Online (Sandbox Code Playgroud)

如果可以的话,请问如何实现?

c# arrays struct marshalling

1
推荐指数
1
解决办法
498
查看次数

如果将数据移动到不同的块,c ++ realloc函数是否对旧数据块应用删除操作?

该功能可以将存储块移动到新位置,在这种情况下返回新位置.
例如,我有一个指向数组的指针:

int *arr; // somewhere next it initialized, filled with elements and etc
Run Code Online (Sandbox Code Playgroud)

在某个地方我需要:

void* location = realloc(arr, NEW_SIZE);
Run Code Online (Sandbox Code Playgroud)

旧的内存块会发生什么?

如果realloc返回不是数学的指针到arr,我应该使用下一个代码吗?:

delete arr;
arr = (int*)location;
Run Code Online (Sandbox Code Playgroud)

c++ memory-management realloc dynamic-memory-allocation

0
推荐指数
1
解决办法
1267
查看次数

是否有可能在JavaScript中使用@"text"将多行字符串分配给C#中的变量?

可能重复:
如何创建多行字符串

在c#中,我可以这样做:

string str = @"asd 
dsa 
blah blah blah";
Run Code Online (Sandbox Code Playgroud)

我怎样才能在JavaScript中做同样的事情?+每个字符串都是坏主意......

javascript text multiline

0
推荐指数
1
解决办法
125
查看次数

无论如何要删除此自定义ProgressBar类中闪烁的文本?

这就是我在条形图上显示的字符串:

public class ProgressBarWithText : ProgressBar
{
    const int WmPaint = 15;
    SizeF TextSize;
    PointF TextPos;

    public ProgressBarWithText()
    {
        this.DoubleBuffered = true;
        this.TextChanged += ProgressBarWithText_TextChanged;
        this.SizeChanged += ProgressBarWithText_SizeChanged;
    }

    public override string Text
    {
        get { return base.Text; }
        set { base.Text = value; }
    }   

    void RecalcTextPos()
    {
        if (string.IsNullOrEmpty(base.Text))
            return;

        using (var graphics = Graphics.FromHwnd(this.Handle))
        {
            TextSize = graphics.MeasureString(base.Text, this.Font);
            TextPos.X = (this.Width / 2) - (TextSize.Width / 2);
            TextPos.Y = (this.Height / 2) - (TextSize.Height / 2); …
Run Code Online (Sandbox Code Playgroud)

c# text flicker progress-bar

0
推荐指数
1
解决办法
1534
查看次数

人们使用 get 属性的原因是什么?放; 而不是字段?

我经常在类中看到属性,而不是字段。它看起来像这样:

class TestClass
{
    public ulong Id { get; set; }
    public string Description { get; set; }
}
Run Code Online (Sandbox Code Playgroud)

人们为什么这样做?他们可以改用字段。我在那里至少看到一个专业人士 - 我们可以将带有ref关键字的字段传递给函数。是否有任何专业人士出于财产或其他原因像那样使用它们?

c# field properties

0
推荐指数
1
解决办法
46
查看次数